A method and apparatus for image compression

ABSTRACT

The invention relates to a method and apparatus for image compression, particularly to an improved block-coding apparatus and method for image compression. Image compression systems such as JPEG and JPEG2000 are known and popular standards for image compression. Many of the advantageous features of JPEG2000 derive from the use of the EBCOT algorithm (Embedded Block-Coding with Optimized Truncation). One drawback of the JPEG2000 standards is computational complexity. This application discloses a relatively fast block-coding algorithm, particularly as compared with the standard JPEG2000 EBCOT algorithm. Computational complexity is reduced.

FIELD OF THE INVENTION

The present invention relates to a method and apparatus for image compression, and particularly, but not exclusively, to an improved block coding apparatus and method for image compression.

BACKGROUND OF THE INVENTION

Image compression systems are known. JPEG and JPEG2000 are popular standards for image compression.

The JPEG2000 algorithm provides a rich set of features that find application in many diverse fields. Some of the most important features are as follows:

-   -   Compression efficiency     -   Quality scalability     -   Resolution scalability     -   Region-of-interest accessibility     -   Parallel computation     -   Optimized rate control without iterative encoding     -   The ability to target visually relevant optimization objectives     -   Error resilience     -   Compressed domain (i.e. very low memory) transposition and         flipping operations     -   Ability to re-sequence information at the code-block, precinct         or J2K packet level

Most of these features derive from the use of the EBCOT algorithm (Embedded Block Coding with Optimized Truncation), while use of the hierarchical Discrete Wavelet Transform (DWT) also plays an important role.

In addition to these core features, the JPEG2000 suite of standards provide good support for the following applications:

-   -   Efficient and responsive remote interactive browsing of imagery         (including video and animations) via JPIP.     -   Efficient on demand rendering of arbitrary regions from huge         imagery sources.     -   High dynamic range compression, through the use of non-linear         tone curves and/or custom floating point mappings.     -   Rich metadata annotation.     -   Efficient compression of hyper-spectral and volumetric content.

A drawback of the JPEG2000 standards is computational complexity. For video applications and for applications that are especially power conscious, compression and rendering complexity can become an obstacle to adopting JPEG2000, despite its many benefits.

SUMMARY OF INVENTION

In accordance with a first aspect, the present invention provides a method of image compression, where image samples are formed into code-blocks, with a block coding process that comprises the following steps:

-   -   coding significance information for a set of samples, using         codes that depend only on the significance of previous samples         in a scanning order;         coding magnitude and sign information for a set of samples,         using codes that depend only on previous magnitude and         significance information in the scanning order;     -   arranging the significance and magnitude code bits on a set by         set basis, such that the significance bits associated with each         set of samples appear together in the coded representation         (codeword segment);     -   repeating the coding and code bit arrangement steps for each set         of samples in the code-block.

In an embodiment, the block coding process comprises the step of collecting samples of the code-blocks into groups, so that a set of samples comprises a group of samples. The significance coding step is applied to groups. In one embodiment, each group comprises four contiguous samples, following a raster scan of the code-block. In another embodiment, each group comprises four contiguous samples, following a stripe oriented scan of the code-block with stripes of height 2, so that the groups have a 2×2 organization within the code-block.

In an embodiment, group significance symbols are coded for certain groups within the code-block, using an adaptive code to communicate whether each such group contains any significant samples, or no significant samples at all. In embodiments, group significance symbols are coded for groups whose already coded spatial neighbours within the code-block are entirely insignificant. In embodiments, the step of coding significance for the samples in a group depends on whether the group is the subject of adaptive group significance symbol coding and the value of any such group significance symbol.

In embodiments, the block coding process comprises the step of producing a single codeword segment which comprises multiple bit-streams. In one embodiment, a forward growing bit-stream and a backward growing bit-stream are used (dual bit-stream) so that the lengths of the individual bit-streams need not be separately communicated, it being sufficient for a decoder to know the length of the codeword segment to which they belong. In another embodiment, three bit-streams are used (triple bit-stream), two growing forward, while one grows backward, and the interface between the two forward growing bit-streams is explicitly identified, in addition to the overall length of the codeword segment which is comprised of the three bit-streams. In embodiments, bit-stuffing techniques are applied within the separate bit-streams of a code-block's codeword segment in order to avoid the appearance of forbidden codes within the final compressed codestream.

In embodiments, the bits produced by adaptive coding of group significance symbols are assigned to their own bit-stream (adaptively coded bit-stream) within the code-block's codeword segment.

In an embodiment, group significance symbols are coded using an adaptive arithmetic coding engine.

In another embodiment, group significance symbols are coded using an adaptive run-length coding engine.

In an embodiment, the step of coding significance for a set of samples is based on context, the context of a set of samples depending only on the significance information that has already been coded for previous sets of samples in the code-block, in scan-line order. In an embodiment, the step of context-based significance coding utilizes variable length codes and a single codeword is emitted for each set of samples that is not otherwise known to be entirely insignificant.

In embodiments, the bits produced by context-based significance coding are arranged within a bit-stream (a raw bit-stream) that is separate from the adaptively coded bit-stream.

In an embodiment, the step of coding magnitude information is based on magnitude contexts, wherein the magnitude context for each sample is formed from the magnitude exponents of its neighbours. In an embodiment, the magnitude context is formed from the sum of the neighbouring sample magnitude exponents.

In an embodiment, the bits used to encode magnitude and sign information for significant samples of a code-block are arranged within the same bit-stream (raw bit-stream) as the context-based significance code bits, but separated so that the significance bits for a set of samples appears before the magnitude and sign bits for the same set of samples. In an embodiment, the sets of samples that form the basis for separating significance and magnitude/sign bits within a bit-stream are whole scan-lines of the code-block.

In another embodiment, the bits used to encode magnitude and sign information are arranged within a separate bit-stream (a raw bit-stream) from the context-based significance code-bits.

In other embodiments, magnitude and sign information for significant samples is separated into a variable length coded part and an uncoded part, where the bits produced by the variable length coded part are arranged within the same bit-stream (VLC bit-stream) as the context-based significance code bits, while the uncoded part is arranged within a separate bit-stream (raw bit-stream). In such embodiments, the significance and magnitude VLC bits are separated within the VLC bit-stream so that the significance VLC bits for a set of samples appear before the magnitude VLC bits for the same set of samples. In an embodiment, said sets of samples that are used to separate significance from magnitude VLC bits correspond to group pairs, where significance coding is based on groups

In an embodiment, the method of image compression complies with the JPEG2000 format and the block coding process described above is used in place of the usual JPEG2000 block coding process.

In an embodiment, the steps of significance and magnitude coding (Cleanup pass) produce a codeword segment (Cleanup segment) that communicates quantized subband samples within a code-block relative to a certain magnitude bit-plane. In an embodiment, an additional codeword segment (SigProp segment) is produced that represents the significance of certain samples within the code-block that were coded as insignificant in the Cleanup pass, relative to the next finer (higher precision) magnitude bit-plane, along with the sign information for samples that are significant only relative to this finer bit-plane. In an embodiment, a further codeword segment (MagRef segment) is produced that holds the least significant magnitude bit, with respect to the finer (higher precision) bit-plane, for samples that are coded as significant in the Cleanup pass. In embodiments, the SigProp pass codes significance information for previously insignificant samples whose neighbours have been coded as significant in either the Cleanup or SigProp pass, following the 4-line stripe-oriented scan, exactly as defined in JPEG2000. In an embodiment, the significance and sign bits produced by the SigProp pass are separated within a single raw bit-stream, so that any new significance bits for a set of samples precede any sign bits for the same set of samples. In an embodiment, the sets of samples that form the basis for arranging significance and sign bits within the SigProp codeword segment consist of 4 samples.

In an embodiment, the method of this invention has the advantage of providing a relatively fast block coding algorithm, particularly as compared with the standard JPEG2000 EBCOT algorithm. In this document, we use the term FBCOT (Fast Block Coder with Optimized Truncation). The Fast Block Coder option has a number of advantages, which will become clear from the following detailed description.

In accordance with a second aspect, the present invention provides an encoding apparatus, arranged to implement a method in accordance with the first aspect of the invention.

In accordance with a third aspect, the present invention provides an encoding apparatus, comprising a block coder arranged to code significance information for a set of samples, to code magnitude and sign information for the set of samples, to arrange the resulting code-bits within the final compressed result (codeword segment), and to repeat the coding steps and code-bit arrangement step for other sets of samples until significance, sign and magnitude information has been coded for all the sets of samples in a code-block.

In accordance with an fourth aspect, the present invention provides a method of image compression complying with the JPEG2000 standard, wherein image samples are formed into code-blocks by a block coding process, the improvement comprising implementing a Cleanup pass in the block coding process, which encodes the information that would be encoded by a corresponding JPEG2000 Cleanup pass, along with the information that would be encoded by all corresponding preceding JPEG2000 coding passes.

In accordance with a fifth aspect, the present invention provides a rate control method that allows a target compressed size to be achieved when compressing an image or sequence of images, with the property that only a limited set of coding pass operations need be performed for each code-block.

BRIEF DESCRIPTION OF THE FIGURES

Features and advantages of the present invention will become apparent from the following description of embodiments thereof, by way of example only, by reference to the accompanying drawings, in which:

FIG. 1 is a diagram of FAST coding passes showing the codeword segments that are produced with/without the RESTART mode flag, as well as examples of coding passes that might be generated by an encoder and ultimately emitted to the codestream;

FIG. 2 is a block diagram of the Cleanup pass encoder (dual bit-stream version);

FIG. 3 is a block diagram of the Cleanup pass encoder (triple bit-stream version);

FIG. 4 is a block diagram of the Cleanup pass encoder (triple bit-stream version with distributed magnitude information);

FIG. 5 is a representation of a dual bit-stream codeword structure for the FAST block coder's Cleanup pass;

FIG. 6 is a representation of a triple bit-stream codeword structure for the FAST block coder's Cleanup pass;

FIG. 7 illustrates a Raster scanning order with linear 1×4 groups, showing parts of the first two lines of a code-block with an even width W that is not divisible by 4. Note that the missing samples of right-most groups are padded with zero's rather than being ignored;

FIG. 8 is an illustration of line-interleaved scanning order with square 2×2 groups, showing a code-block with 3 lines of odd width W. Note that the missing samples within each group that overlaps the code-block are padded with zero's rather than being ignored;

FIG. 9 is a representation of a line-interleaved sequencing of significance and magnitude/sign information for dual bit-stream versions of the FAST Cleanup pass. The illustration here is not specific to the 1×4 linear group structure, but for 2×2 groups W should be interpreted as twice the code-block width;

FIG. 10 is a representation of fully de-coupled processing of significance and magnitude/sign information for triple bit-stream versions of the FAST Cleanup pass. The illustration here is not specific to the 1×4 linear group structure, but for 2×2 groups W should be interpreted as twice the code-block width;

FIG. 11 is a diagram of information used for significance coding in linear 1×4 group g;

FIG. 12 is an illustration showing information used for significance coding in square 2×2 group g;

FIG. 13 is a representation of neighbouring magnitude exponents used to form magnitude coding contexts for E[n], shown separately for the case where E[n] does and does not belong to the first line of its code-block;

FIG. 14 is an illustration showing quantities involved in distributed magnitude coding for linear 1×4 groups (top) and square 2×2 groups (bottom), except in the initial row of groups within a codeblock;

DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION

Brief Review of the JPEG2000 Block Coding Algorithm

The existing JPEG2000 block coding algorithm processes the subband samples within each code-block through a sequence of coding passes. It is helpful to briefly revise this in order to explain the different, yet related coding pass structure of the FAST block coding algorithm in the next section.

Let X[n] denote the samples within a code-block, indexed by location n=(n₁,n₂), where 0≤n₁<W represents horizontal position, 0≤n₂<H denotes vertical position, and W and H are the code-block's width and height, respectively. Each coding pass belongs to a bit-plane index p≥0, with respect to which the quantized magnitude of sample X[n] is given by

${M_{p}\lbrack n\rbrack} = \left\lfloor \frac{{X{n}}}{2^{p}\Delta} \right\rfloor$

Here, Δ is the quantization step size, that is not present for reversible coding procedures.

We say that sample X[n] is “significant” with respect to bit-plane p if M_(p)[n]≠0.

The finest bit-plane (highest quality) corresponds to p=0, while the coarsest quality corresponds to p=K−1, where K is the maximum number of bit-planes for any code-block belonging to a given subband, determined by subband-specific parameters recorded in codestream headers.

For each code-block a parameter M_(start) is communicated via the relevant JPEG2000 packet headers, which is interpreted as the number of missing bit-planes in the code-block's representation. The JPEG2000 block decoder is entitled to expect that all samples in the code-block are insignificant in bit planes p≥K−M_(start). Equivalently, the total number of bit-planes that may contain significant samples is given by

P=K−M _(start)

The first coding pass in the JPEG2000 block coding algorithm encodes the significance information and sign (for significant samples only) for bit-plane p=P−1. This coding pass is identified as a “Cleanup” pass. Importantly, any significant sample coded in this cleanup pass must have magnitude 1.

For each successively finer bit-plane, three coding passes are produced, identified as the “SigProp” (significance propagation) and “MagRef” (magnitude refinement) coding passes. In total then, there are 3P−2 coding passes, with the following structure.

-   Cleanup (p=P−1): Codes significance, in bit-plane p, of all samples,     plus the sign of significant samples. -   SigProp (p=P−2): Visits insignificant neighbours of known     significant samples, coding their significance (and sign), in plane     p. -   MagRef (p=P−2): Visits samples that were already significant with     respect to plane p+1, coding the least significant bit of M_(p)[n]. -   Cleanup (p=P−2): Codes significance (and sign), in bit-plane p, of     all samples whose significance has not yet been established. -   SigProp (p=P−3): . . . -   MagRef (p=P−3): . . . -   Cleanup (p=P−3): . . . -   . . . -   Cleanup (p=0): . . .

Note that the encoder may drop any number of trailing coding passes from the information included in the final codestream. In fact, the encoder need not generate such coding passes in the first place if it can reasonably anticipate that they will be dropped.

In the standard JPEG2000 block coding algorithm, all coding passes adopt a stripe oriented scanning pattern, with 4 line stripes. The columns of each stripe are visited from left to right before moving to the next stripe, while inside each stripe column the 4 samples of the stripe column are scanned from top to bottom.

The JPEG2000 block coder employs arithmetic coding for all symbols in the cleanup pass, but can optionally just emit raw (uncoded) bits in the SigProp and MagRef coding passes. This mode, in which raw bits are emitted for the non-cleanup passes, is identified as the “arithmetic coder bypass” mode, or just the “BYPASS” mode for short

Key Elements of the FAST Block Coding Algorithm in Accordance with this Embodiment of the Invention

Coding Pass Structure

The FAST block coder also adopts a coding pass structure, with Cleanup, SigProp and MagRef coding passes, defined with respect to bit-planes p. Significantly, however, the Cleanup pass associated with each bit-plane p fully encodes the magnitudes M_(p)[n] and the signs of those samples for which M_(p)[n]≠0. This information completely subsumes that associated with all previous (larger p) coding passes, so that there is no point in emitting them to the codestream.

It follows that both leading and trailing coding passes may be dropped (or never generated) by the encoder, so long as the first emitted coding pass is a Cleanup pass. In fact, it never makes sense for an encoder to actually include more than 3 coding passes for any given code-block in the final codestream. FIG. 1 illustrates the coding passes that might be generated by the FAST block encoder and/or emitted to the final codestream.

From a decoder's perspective the M_(start) value that is recovered by parsing the JPEG2000 packet headers still serves to identify the bit-plane index p=K−M_(start)−1 associated with the first available coding pass for the code-block. However, since the FAST Cleanup pass can encode multiple magnitude bits for any given sample, M_(start) can no longer be interpreted as the number of leading magnitude bits that are all 0. Encoders should be careful to ensure that M_(start) correctly describes the first emitted coding pass for each code-block.

The SigProp and MagRef coding passes generated by the FAST block coder do not depend on each other; they depend only on the immediately preceding Cleanup pass. The SigProp and MagRef coding passes generated by the FAST block coder encode exactly the same information as in JPEG2000, so that the effective quantization associated with truncating the representation at the end of a Cleanup, SigProp or MagRef pass is the same, regardless of whether the FAST block coding algorithm or the standard JPEG2000 block coder is used.

All significance and associated sign information from the SigProp pass is emitted as raw binary digits and all magnitude refinement information from the MagRef pass is emitted as raw binary digits, where these raw bit-streams are subjected only to bit-stuffing procedures that are consistent with the JPEG2000 requirement to avoid the appearance of false marker codes in the range FF90h to FFFFh¹. ¹ Actually, bit-stuffing in JPEG2000 raw codeword segments avoids the appearance of byte pairs whose big-endian hex value lies in the range FF80h to FFFFh, but the block coding algorithm in general is only required to avoid marker codes in the range FF90h to FFFFh.

The MagRef pass adopted by the FAST block coding algorithm is identical to that of the standard JPEG2000 block coder, operating in the arithmetic coder bypass mode (BYPASS mode, for short), except that code bits are packed into bytes of the raw bit-stream with a little-endian bit order. That is, the first code bit in a byte appears in its LSB, as opposed to its MSB.

The SigProp coding pass adopted by the FAST block coding algorithm is also very similar to that of the standard JPEG2000 block coder, operating in the BYPASS mode, with the following differences:

-   -   1. Code bits are again packed into bytes of the raw bit-stream         with a little-endian bit order, whereas the JPEG2000 coder uses         a big-endian bit packing order.     -   2. For stripes of height 3 or height 4 the significance bits         associated with each stripe column are emitted first, followed         by the associated sign bits, before advancing to the next stripe         column.     -   3. For stripes of height 2, the significance bits associated         with each pair of stripe columns are emitted first, followed by         the associated sign bits, before advancing to the next pair of         stripe columns.     -   4. For stripe columns of height 1, the significance bits         associated with each group of four stripe columns (4 samples)         are emitted first, followed by the associated sign bits, before         advancing to the next group of four stripe columns.

These modifications together have implementation advantages over the original JPEG2000 methods, especially for software based implementations. We note that the last three modifications are consistent with the principle of separating significance information from other aspects of the sample data, a principle which we adopt on a larger scale for the Cleanup pass, as explained below. These last three modifications are carefully crafted to allow accelerated decoding based on modest lookup tables. The last two modifications are important only for applications in which short and wide code-blocks are expected to occur frequently—especially low latency applications. For other applications, it may be appropriate to extend the second modification to cover all stripe heights and eliminate the last two.

Apart from the block coding algorithm itself, the FAST block coder has no impact on other JPEG2000 codestream constructs or their interpretation. Precincts, packets, tiles, transforms, and all other JPEG2000 elements remain unchanged. In particular, the construction of JPEG2000 packets depends upon the codeword segments that are produced by the block coder, regardless of whether the conventional block coding algorithm or the FAST block coding algorithm is used.

A codeword segment is a sequence of bytes, whose length is necessarily identified via the packet header. The standard JPEG2000 block coder may pack all coding passes into a single codeword segment (default mode); in the RESTART mode, however, each coding pass is assigned its own codeword segment, while in the BYPASS mode(s) without RESTART, SigProp and MagRef coding passes are collectively assigned a codeword segment.

The FAST block coder supports all of the mode flags defined for the standard JPEG2000 block coder, except for the BYPASS mode flag, which is implied, and the RESET mode flag which has no meaning. Since no more than 3 coding passes are emitted to the codestream, and BYPASS is implied, there are only two types of codeword segments that can arise, depending on the RESTART mode flag, as shown in FIG. 1. The CAUSAL mode must be retained, as an option, to ensure completely reversible transcoding to/from all standard JPEG2000 block bit-streams, since the CAUSAL mode affects the interpretation of the SigProp coding pass.

Cleanup Pass Overview

The remainder of this section is devoted to describing the FAST block coder's Cleanup pass. Before proceeding, it is helpful to provide a summary block diagram for the encoder. To facilitate later discussion, we provide the encoding block diagram in several versions, corresponding to several different variants of the FAST cleanup pass that are covered by this document. The variants are distinguished in two main ways, as follows:

-   -   1. Each variant has either a dual bit-stream structure, or a         triple bit-stream structure. The dual bit-stream structure is         conceptually simpler, and very slightly more efficient, from a         compression point of view, but the triple bit-stream structure         provides more options for software and hardware optimization,         and so is generally to be preferred. The dual bit-stream         structure interleaves VLC and MagSgn bits within one bit-stream,         while the triple bit-stream structure provides separate VLC and         MagSgn bit-streams.     -   2. The other distinguishing feature is whether the magnitude         information for each significant sample is consolidated within         one bit-stream (the MagSgn bit-stream) or distributed between         the VLC bit-stream and the MagSgn bit-stream. The distributed         approach provides slightly less opportunity to exploit         statistical redundancy, but improves software decoding         throughput and increases hardware decoding clock rates, by         reducing or eliminating sample-to-sample dependencies. The         distributed approach also reduces the worst case data rate         associated with the MagSgn bit-stream, which is better for         hardware implementations.

FIG. 2 provides an encoder block diagram for the dual bit-stream structure with consolidated magnitudes. FIG. 3 provides the corresponding block diagram for the triple bit-stream structure, again with consolidated magnitudes. Finally, FIG. 4 shows the encoding procedure for the triple bit-stream variant with distributed magnitude information. We do not bother to explicitly present the variant with dual bit-streams and distributed magnitude information here, but its block diagram should be apparent from those already provided. The elements of these block diagrams are explained in the following sub-sections, but the “storage” element perhaps deserves some clarification up front.

The storage element represents a buffer that can store the code-block's samples, as well as some deduced state information. During encoding, the storage element is populated with subband samples, after which the derived quantities (significance flags and magnitude exponents) can be found immediately. The storage element need not necessarily accommodate all samples or derived quantities for the entire code-block, but it is easiest to conceptualize things this way.

Dual or Triple Bit-Streams in the Cleanup Pass

As mentioned, for compatibility with the JPEG2000 codestream structure, the FAST block coder's Cleanup pass produces a single codeword segment whose length is communicated for the relevant packet header(s) via the existing methods. In the FAST block coder, however, this codeword segment is divided into two or three bit-streams:

A. an adaptively coded bit-stream, which grows forwards; B. a raw bit-stream that grows backwards from the end of the codeword segment; and C. in some variants, a second raw bit-stream that grows forwards from the start of the codeword segment.

The term “adaptively coded” here identifies the presence of a context-adaptive entropy coder, which learns and adapts to symbol statistics in one way or another. By contrast, the raw bit-streams just consist of packed bits, apart from mandatory bit-stuffing to avoid false marker codes (see below). Various adaptive coding technologies can be employed, of which this document describes two that are of particular interest: a) the MQ arithmetic coder from JPEG2000; and b) a MEL coding algorithm, similar to that used by JPEG-LS. As it turns out, both offer very similar compression efficiency and similar state transition patterns, but the MEL coding approach has a smaller state machine and so is generally preferred.

FIG. 5 illustrates the dual bit-stream arrangement. Referring to the corresponding block diagram of FIG. 2, the raw bit-stream here includes VLC significance codewords, as well as magnitude and sign bits, interleaved on a line-by-line basis.

FIG. 6 illustrates the triple bit-stream arrangement, in which VLC significance codewords are completely separated (decoupled) from the magnitude and sign bits, rather than being interleaved—see FIG. 3. The triple bit-stream arrangement is slightly less efficient, since extra signalling (the interface locator word) is required to identify the boundary between the two forward growing bit-streams. There is no need, however, to explicitly identify the boundary between forward and reverse growing bit-streams, which can be disjoint, meet in the middle or even overlap, so long as this does not interfere with correct decoding.

Here, the objective is to enable the use of different coding technologies, representing different trade-offs between processing complexity and coding efficiency, while still presenting only one codeword segment to the packet generation and parsing machinery for maximum compatibility with the existing JPEG2000 standard.

The use of two different bit-streams within a single codeword segment has significant advantages in enabling concurrent/parallel processing. The adaptively coded bit-stream associated with the FAST block coder can be encoded and decoded independently from the other bit-stream(s). In advanced decoder implementations, some or all of the adaptively coded symbols might be decoded well ahead of the raw symbols whose decoding depends upon them. Encoders can defer the adaptive encoding steps until after some or all of the raw bits have been emitted for a code-block, which is beneficial in software implementations and may well be beneficial for hardware deployments.

While slightly less efficient, the triple bit-stream arrangement is preferred on the grounds that it provides even greater levels of concurrency, supporting greater levels of flexibility in the ordering of encoding and decoding processes. These can be especially beneficial in hardware. As described shortly, the coding processes are such that significance information can be encoded or decoded independently of the magnitude and sign information. This means that a decoder can process the adaptively coded bit-stream without reference to the other two bit-streams and can process the VLC raw bit-stream without reference to the MagSgn raw bit-stream. Encoders can generate all three bit-streams concurrently if desired, without the synchronization constraints imposed by the interleaving operation of the dual bit-stream variant. A further important advantage of the triple bit-stream arrangement is that both encoders and decoders can process any significance propagation (SigProp) or magnitude refinement (MagRef) passes concurrently with the Cleanup pass, without substantial inter-pass delays.

These properties facilitate guaranteed single clock per sample processing for hardware implementations of the block coder, which combines with the availability of multiple code-blocks to enable very high data throughputs to be obtained at low clock rates.

The benefits that the dual and triple bit-stream structures bring in concurrency and decoupling are independent of the order in which the bit-streams evolve, so there are of course other very closely related bit-stream arrangements that could be considered. We prefer the arrangement in FIG. 6 for a number of reasons, which may be appreciated from the following points.

-   -   1. The MagSgn bit-stream tends to be the largest of the         bit-streams at high bit-rates, so there is some benefit to         having this one grow forwards from the start of the codeword         segment, minimize the effort required to rearrange the generated         bytes at the end of each code-block.     -   2. The combined size of the VLC bit-stream and the adaptively         coded bit-stream can be deterministically bounded.     -   a. With consolidated magnitude information, where all magnitude         related bits for the significant samples are found in the MagSgn         bit-stream alone, this bound can be shown to satisfy         S_(max)<1020 bytes, subject to suitable choices for the codes         that are employed within the VLC bit-stream, allowing us to         signal the boundary between two forward growing bit-streams         using an L=10-bit interface locator word (ILW).     -   b. For variants which distribute the coded magnitude information         between the VLC bit-stream and the MagSgn bit-stream, the         combined size of the VLC and adaptively coded bit-streams         increases, with a bound that can be shown to satisfy         S_(max)<2040 bytes, subject to suitable choices for the codes         that are employed with the VLC bit-stream. This allows us to         signal the boundary between the two forward growing bit-streams         using an L=11-bit interface locator word (ILW).

Placing the L-bit (i.e, 10- or 11-bit) ILW at the end of the codeword segment, with its 8 MSB's appearing in the last byte, has the benefit that a terminal “FFh” is avoided (a JPEG2000 requirement). The L−8 (i.e., 2 or 3) LSB's of the ILW occupy the least significant L−8 bit positions of the codeword segment's second last byte, whose other 16-L (i.e., 6 or 5) bits are then available for code bits.

-   -   3. If extra bytes need to be stuffed between the two forward         growing segments to avoid buffer underflow in CBR applications,         the stuffing location can easily be found, even after multiple         codeword segments have been emitted to a codestream buffer,         simply by reading the last two generated bytes.

The concurrency benefits of the multiple bit-stream arrangements here are also independent of the choice of adaptive coding algorithm used for the adaptively coded bit-stream. In the next two sub-sections, we provide specific details and considerations for the two adaptive coding technologies that we have explored in depth: MQ and MEL coding.

The entire codeword segment is required to be free from false marker codes in the range FF90h to FFFFh, which is a general requirement found in multiple ISO/IEC image coding standards. That is, no pair of bytes should have the property that the hex value of the first is FFh, while that of the second is in the range 90h to FFh. Additionally, the JPEG2000 standard requires that the terminal byte of a codeword segment may not be FFh, so as to allow later re-arrangement of codeword segments, without the risk of creating false marker codes. The MQ arithmetic coder used in JPEG2000 and also in JBIG2 already has the property that it cannot emit false marker codes.

For other adaptive coding algorithms, bit-stuffing needs to be introduced separately to avoid false marker codes, as described below for the case of MEL coding.

For forward growing raw bit-streams, false marker codes are avoided using the same strategy as the raw bit-streams produced in the JPEG2000 block coder's BYPASS mode. Specifically, the byte following an emitted FFh contains only 7 valid bits, with 0 stuffed into its most significant bit position.

The raw bit-stream that grows backward from the end of the Cleanup codeword segment avoids false marker codes as follows. Bits are emitted from the coding procedure to the raw bit-stream via an emit raw operation, which packs bits into bytes starting from the least significant bit position. Once a byte has been assembled, it is combined with the last emitted byte (0 if there is none) to form a 16-bit big-endian unsigned integer V. If the encoder finds that

-   -   (V & 7FFFh)>7F8Fh         then the most significant bit of V is reset before emitting the         newly generated byte, after which the bit that was just removed         is passed to emit-rraw so that it becomes the least significant         bit of the next byte.

There are, of course, fast implementations that are equivalent to the bit-stuffing strategy described above². The decoder watches for the same condition to remove the stuffing bit as it reads bytes (backwards) from the raw bit-stream. ² For software implementations, all bit-stuffing procedures can be efficiently vectorized, so that individual byte-oriented tests are not required.

An alternate bit-stuffing approach could be considered in which the condition tested is simply

-   -   (V & 7F80h)≠0

This approach is very slightly simpler, at the expense of a similarly tiny reduction in compression efficiency.

Care must be taken at the interface between the bit-streams, to ensure that no false marker codes are generated there either. To do this, encoders may need to insert an additional byte, or flip unused bits at the tail of one or another of the bit-streams.

For the dual bit-stream arrangement, the encoder addresses the requirement that the last byte of the codeword segment is not FFh, by emitting a stuffing bit (i.e. 0) to the backward growing raw bit-stream as its very first step; this stuffing bit is consumed by the decoder before any valid bits.

For the triple bit-stream arrangement, no initial stuffing bit is required, since the backward growing VLC raw bit-stream starts from the last 16-L (i.e, 6 or 5) bits of the second last byte of the codeword segment, the last L (i.e., 10 or 11) bits being occupied by an interface locator word, whose final byte that cannot be as large as FFh. For the purpose of the bit-stuffing and bit-unstuffing algorithms, the last L bits of the codeword segment are treated as if they were all l's; this allows the encoder to perform bit-stuffing and generate completed bytes for all bit-streams without any dependence on the L-bit value which will be inserted into the interface locator word.

In a practical implementation, this may be achieved by actually emitting L place-holder bits (all equal to 1) to the VLC raw bit-stream prior to encoding, overwriting these bits with the ILW value after all encoding is complete. Meanwhile, the decoder can first extract the ILW to determine S, replacing the corresponding L bits with 1's, and then pass all S suffix bytes to the bit-unstuffing machinery associated with the VLC raw bit-stream; in this approach, the L place-holder bits would be consumed from the VLC raw bit-stream and discarded before actual block decoding commences.

For the triple bit-stream arrangement, the decoder always appends a single FFh at the end of the MagSgn bit-stream prior to ingesting its bits to decode magnitude and sign information. Accordingly, the encoder can, and generally should discard any terminal FFh that would otherwise be emitted to the MagSgn bit-stream, avoiding any possibility that false marker codes arise at the interface between the two forward growing bit-stream segments.

MQ Adaptive Arithmetic Coding

While arithmetic coding is an extremely powerful and flexible technology, the FAST block coder uses adaptive coding to represent a variable length string of binary symbols σ_(AZC)[i], known as AZC symbols. As explained below, these samples all have identical (all-zero) neighbourhoods, so there is no a priori way to separate them into sub-classes with different statistics. Accordingly, only one adaptive MQ coding context need be employed, which simplifies both encoding and decoding implementations.

The MQ coder employs a state machine with 46 reachable states, where state transitions occur only on renormalization events. Renormalization always occurs when an LPS (least-probable symbol) is coded, where the LPS almost invariably corresponds to σ_(AZC)[i]=1. Additionally, one MPS (most-probable symbol) renormalization event typically occurs between LPS symbols. Thus, approximately two state transitions can be expected for each run of 0 AZC symbols that is terminated by a 1. In fact, the MQ coder can be understood as a type of run-length coder, with a lineage that can be traced back to the “skew coder,” which is nothing other than an efficient run-length coding algorithm.

While details of the MQ coding algorithm need not be repeated here, we point out that the dual bit-stream structure employed by the FAST block coder has an impact on the choice of MQ termination strategy. The simplest approach is to use the well-known Elias termination methodology, in which the interval base register C of the MQ coder is augmented by 2¹⁴ (the MQ interval length register A is 16 bits wide) and bytes are flushed from the coder until this added bit 14 has been flushed. If the last flushed byte is FFh, one additional byte might then need to be emitted between the MQ and raw bit-streams of the Cleanup bit-stream segment to avoid false marker codes.

Truly optimal MQ bit-stream terminations are also possible, of course, at a larger cost in complexity that is unlikely to be warranted. Minimal length MQ terminations often share some of their information bits with the raw bit-stream and achieve an average reduction in overall Cleanup codeword segment length of approximately 6 bits relative to the Elias termination approach described above.

MEL Adaptive Coding Algorithm

The MELCODE is most easily understood as an adaptive run length code. For convenience of explanation, therefore, we consider that the AZC symbol stream σ_(AZC)[i] is first converted to a sequence of run lengths R_(AZC)[j], where each run represents the number of 0's that precede the next 1. Since there is at most one AZC symbol for every group of 4 code-block samples, and no code-block may have more than 4096 samples, the maximum run-length that need be coded is 1024—this corresponds to an entirely insignificant code-block so should not normally occur, but we allow for the possibility nonetheless. This allows a non-empty codeword segment to be used to represent an entirely empty code-block, which is inefficient, but can be useful for the avoidance of buffer underflow in CBR applications.

The MEL coder used in the JPEG-LS standard has 32 states, but we find it helpful to define a different state machine for the FAST block coder, with only 13 states state indices k in the range 0 to 12. Each state k is associated with an exponent E_(MEL)[k] and a threshold T_(MEL)[k]=2^(E) ^(MEL) ^([k]). Table 1 lists the values of the key quantities.

TABLE 1 MEL coding state machine State k exponent E_(MEL) threshold T_(MEL) next state, hit next state, miss 0 0 1 1 0 1 0 1 2 0 2 0 1 3 1 3 1 2 4 2 4 1 2 5 3 5 1 2 6 4 6 2 4 7 5 7 2 4 8 6 8 2 4 9 7 9 3 8 10 8 10 3 8 11 9 11 4 16 12 10 12 5 32 12 11

The MELCODE is an adaptive Golomb code for the run lengths R_(AZC)[j], where the threshold T_(MEL)[k] plays the role of the Golomb parameter. Ignoring the adaptation, the coding procedure can be summarized as:

-   -   while R≥T, emit 1 (a “hit”) and subtract T from R emit 0 (a         “miss”), followed by the E LSB's of R

The optimal Golomb parameter for an exponentially distributed information source is a little over half of its mean value. Thus, a typical run R should be coded by one hit followed by a miss. This implies that the adaptive state machine should (on average) experience one hit and one miss for each run, which is achieved by incrementing the state after each hit and decrementing the state after each miss, as shown in Table 1.

The complete MEL coding algorithm is as follows:

Initialize k=0 For each j=0,1,... Set R ← R_(AZC)[j] While R ≥ T_(MEL)[k] Emit “1” (“hit”) Update R ← R − T_(MEL)[k] Update k ← min{k + 1,12} Emit “0” (“miss”) Emit E_(MEL)[k] LSB's of R Update k ← max{k − 1,0}

While the algorithm is expressed in terms of run length coding, it can always be re-cast as an adaptive state machine that operates on individual symbols, just as the MQ coder can be recast as a state machine that operates on runs. As an encoder for individual AZC symbols, the MEL coder here cannot produce more than 6 code bits, but often produces no bits at all. Both MQ and MEL coding approaches exhibit roughly the same number of state transitions, but the advantage of the MEL coder is that it has a very small state machine. For the purpose of multi-symbol coding, the MQ coder's state machine can be considered to consist of both the MQ state index and the 16-bit A register, while our MEL coder has only a 4-bit state index. In software implementations at least, it is advisable to use small lookup tables to drive the encoding and decoding of runs, where in most cases a single lookup suffices to encode or decode a complete run.

The bits emitted by the MEL coder are packed into bytes in big-endian fashion, starting from the MSB and working down to the LSB. Moreover, to prevent the appearance of false marker codes, a 0 bit is stuffed into the MSB of any byte that follows an FFh.

More often than not, the last AZC symbol in a code-block is 0, so that the final run is actually “open,” meaning that encoding a larger run does not interfere with correct decoding of the AZC symbols. Additionally, the final byte produced by the MEL coder often contains one or more unused LSB's. With these things in mind, various termination strategies can be devised for the MEL coded bit-stream. As with an MQ coded bit-stream, the bytes that belong to the MEL bit-stream may partially overlap those belonging to the raw bit-stream within the cleanup codeword segment, so long as correct decoding is assured.

It should be apparent that the sequencing policies for bits and bytes in the various bit-streams of the FAST block coder can be modified in various ways without changing the key operating principles. For example, one could arrange for a backward growing MEL coded bit-stream to meet a forward growing raw bit-stream. One could also arrange for bits in the raw bit-stream to be packed in big-endian order, with those in the MEL coded bit-stream packed in little-endian order, while still allowing enabling termination strategies at the interface between the two bit-streams. However, a little-endian bit packing order tends to bring benefits for software implementations, so it makes sense to adopt the little-endian order for the raw bit-streams, which are typically larger than the adaptively coded bit-stream.

Cleanup Pass Groups and Scanning Patterns

An important property of the FAST block coding algorithm is that significance information for the Cleanup pass is collected in groups and coded ahead of other information.

Efficient coding of significance is very important, especially at lower bit-rates, where half or more of the coded bits may be expended identifying which samples in the code-block are significant (i.e., non-zero). The FAST block coder uses a fixed set of VLC codewords to identify the significance (or otherwise) of all samples in a group at once. Additionally, the FAST block coder identifies certain groups of samples, known as AZC (All-Zero Context) groups, as likely to be entirely insignificant; an adaptive (MQ or MEL) coding engine is used to efficiently encode whether or not each AZC group actually is entirely insignificant.

Since groups play such an important role, their size and geometry is important. Empirical evidence strongly suggests that groups of size 4 provide the best trade-off between complexity and coding efficiency. With smaller groups, adaptive AZC group coding tends to be more effective, and VLC codewords can be small. With larger groups, the significance of more samples can be coded at once, but VLC codewords become too long to manage with small tables.

In this document we describe variants of the FAST block coding algorithm that are based on two types of groups, each with 4 samples:

-   -   1. Linear (or 1×4) groups consist of 4 horizontally adjacent         samples within a single scan-line. If the code-block width is         not divisible by 4, the last group within each scan-line is         padded with zero-valued samples.     -   2. Square (or 2×2) groups consist of two consecutive columns         from a stripe of 2 consecutive code-block rows. Code-blocks         whose width or height is not divisible by 2 are again simply         padded with 0's, for simplicity.

These two different group structures (and potentially others) can be considered equivalent subject to a rearrangement of the samples, which amounts to a change in the order in which samples are visited for coding purposes—i.e., the scanning pattern. FIG. 7 and FIG. 8 show the scanning patterns associated with the two group structures identified above. In each case, a group consists of 4 consecutive samples in scan order, with missing samples padded with 0. While 0 padding introduces inefficiencies, it simplifies implementations that need to deal with code-blocks that are truncated at subband boundaries. Evidently, the 2×2 square group structure is transformed into the 1×4 linear group structure by interleaving each pair of code-block scan-lines into one scan-line with twice the width.

The linear group structure has the advantage that the code-block is coded in a line-by-line fashion, which has the potential to minimize overall latency of the algorithm. On the other hand, the advantage of square groups is that it is better suited to high throughput software implementations when working with code-blocks with modest width—e.g., 32×32 code-blocks. Compression performance results presented in Section Error! Reference source not found. suggest that the 2×2 group structure may perform slightly better than the 1×4 linear structure.

Significance Coding

As mentioned above, significance is coded on a group basis. Each group g has a binary significance state σ_(g) that is 1 if any sample in the group is significant, else 0. Additionally, group g has a 4-bit significance pattern ρ_(g), in the range 0 to 15, each bit of which (from LSB to MSB, in scanning order) is 1 if the corresponding sample in the group is significant. Evidently, σ_(g)=0⇔ρ_(g)=0.

For the purpose of significance coding, each group is assigned a coding context c_(g) that depends only on the significance information associated with previous groups, visited in the scanning order. This is important, since it allows significance to be decoded ahead of the magnitude and sign information, which improves computational throughput, at least in software implementations of both the encoder and decoder, and also allows SigProp and MagRef coding passes to be encoded and decoded in parallel with the Cleanup pass.

Groups for which c_(g)=0 are said to be in the All-Zero-Context (AZC) state. In practice, these are groups whose causal neighbours are all insignificant, which explains the term AZC. Adaptive coding is employed only to code the significance σ_(g) of AZC groups, as explained in Sections 4.4 (MQ coding) and 0 (MEL coding) above. Specifically, the binary symbols σ_(g) associated with each AZC group in sequence are concatenated to form a variable length binary string σ_(AZC)[i], which is subjected to one of the variable coding techniques described above. The encoding and decoding of this AZC symbol string need not be synchronized with any other encoding or decoding steps.

For non-AZC groups, and AZC groups that are significant (i.e., σ_(g)=1) the significance pattern ρ_(g) is encoded using variable length coding (VLC), emitting the resulting codewords directly to the raw VLC bit-stream, where they are subjected only to the bit-stuffing procedures described previously. A separate set of VLC codewords is used for each group context c_(g). Efficient implementations can use VLC tables whose entries are formulated to facilitate the generation of context labels for subsequent groups.

As mentioned above, the significance information is coded/decoded separately from some or all of the magnitude and sign information, which introduces a degree of decoupling into implementations of the FAST block coder. In this document, it is helpful to use the term “MagSgn bits” to refer to the binary digits that encode magnitude and sign information for the significant samples. With the dual bit-stream arrangement of FIG. 5, VLC codewords and MagSgn bits are interleaved within a single raw bit-stream on the basis of a row of groups (i.e., line by line for 1×4 linear groups, or line-pair by line-pair for 2×2 square groups), as shown in FIG. 2. That is, for each row of groups within the code-block, all VLC codewords associated with group significance coding are emitted to the raw bit-stream before the MagSgn bits are emitted for the significant samples in that row of groups. FIG. 9 illustrates these concepts.

With the triple bit-stream arrangement of FIG. 6, the encoding and decoding of significance information is fully decoupled from the magnitude and sign bits, providing tremendous flexibility in the sequencing of encoding and decoding operations within both the encoder and decoder. The flow of information for this arrangement is depicted in FIG. 10.

As mentioned earlier, important variants of the FAST block coder actually distribute the magnitude information between the VLC and MagSgn bit-streams. In this case, the VLC bits are augmented, but it is unnecessarily distracting to show this explicitly in the figures.

Group Significance Contexts for Linear Groups

Here we describe a specific set of group significance contexts c_(g) that are used in our current implementation, when working with linear 1×4 groups. Let ρ_(g−1) denote the significance pattern of the group to the left (0 if there is none), let σ_(g) ^(p) denote the significance of the sample to the left, let σ_(g) ^(pp) denote the significance of the sample two to the left, and let σ_(g) ⁰ through σ_(g) ⁵ denote the significance of the six samples centred above group g on the previous scan-line (each 0 if it does not exist), as shown in FIG. 11.

Then, for the first scan-line of the code-block,

$c_{g} = \left\{ \begin{matrix} 0 & {{{if}\mspace{14mu}\left( {\sigma_{g}^{pp}❘\sigma_{g}^{p}} \right)} = {0\mspace{14mu}\left\lbrack {{this}\mspace{14mu}{is}\mspace{14mu}{the}\mspace{14mu}{AZC}\mspace{14mu}{condition}} \right\rbrack}} \\ 4 & {{{{{if}\mspace{14mu}\sigma_{g}^{pp}} = 1},{\sigma_{g}^{p} = 0}}\mspace{290mu}} \\ 5 & {{{{{if}\mspace{14mu}\sigma_{g}^{p}} = 1},{\rho_{g - 1} \neq 15}}} \\ 7 & {{{{if}\mspace{14mu}\rho_{g - 1}} = 15}} \end{matrix} \right.$

while for all other scan-lines,

$c_{g} = \left\{ \begin{matrix} 0 & {{{if}\mspace{14mu}\left( {\sigma_{g}^{p}❘{\sigma_{g}^{0}❘{\sigma_{g}^{1}❘{\sigma_{g}^{2}❘{\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}}}}}} \right)} = {0\mspace{14mu}\left\lbrack {{this}\mspace{14mu}{is}\mspace{14mu}{the}\mspace{14mu}{AZC}\mspace{14mu}{condition}} \right\rbrack}} \\ 1 & {{{{{if}\mspace{14mu}\left( {\sigma_{g}^{p}❘{\sigma_{g}^{0}❘{\sigma_{g}^{1}❘\sigma_{g}^{2}}}} \right)} = 0},{\left( {\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}} \right) = 1}}\mspace{256mu}} \\ 2 & {{{{{if}\mspace{14mu}\left( {\sigma_{g}^{p}❘{\sigma_{g}^{0}❘{\sigma_{g}^{1}❘\sigma_{g}^{2}}}} \right)} = 1},{\left( {\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}} \right) = 0},{\rho_{g - 1} \neq 15}}\mspace{135mu}} \\ 3 & {{{{{if}\mspace{14mu}\left( {\sigma_{g}^{p}❘{\sigma_{g}^{0}❘{\sigma_{g}^{1}❘\sigma_{g}^{2}}}} \right)} = 1},{\left( {\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}} \right) = 1},{\rho_{g - 1} \neq 15}}\mspace{135mu}} \\ 6 & {{{{{if}\mspace{14mu}\left( {\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}} \right)} = 0},{\rho_{g - 1} = 15}}\mspace{391mu}} \\ 7 & {{{{{if}\mspace{14mu}\left( {\sigma_{g}^{3}❘{\sigma_{g}^{4}❘\sigma_{g}^{5}}} \right)} = 1},{\rho_{g - 1} = 15}}\mspace{391mu}} \end{matrix} \right.$

The actual numerical values of c_(g) are not important, although they have been chosen because they can be computed efficiently in both hardware and software. The notation a|b here means logical OR of binary digits a and b. There are 8 contexts in total, with contexts 7 and 0 available to all lines in the code-block. Context 0 always means that all of the samples used to form the contexts are insignificant—the AZC context. Conversely, context 7 means that all of the samples used to form the contexts are significant. The contexts associated with non-initial scan-lines are substantially formed from two binary digits, one of which is 1 if the first sample of the group has a significant neighbour, while the other is 1 if the last sample of the group has a significant neighbour.

In software, it is possible for a decoder to index a single VLC lookup table that incorporates all contexts, using an index that is computed from a simple function of the significance states in the previous scan-line (can be computed using vector arithmetic), logically OR'd with the masked output of the previous group's VLC table and the next 6 bits from the raw bit-stream, assuming a suitable structure for the VLC table entries. This can lead to very high decoding throughput. Encoders are inherently simpler since their context information can all be computed using highly parallel byte-oriented vector arithmetic.

Group Significance Contexts for Square Groups

With the 2×2 square group structure, the significance coding contexts used in our current implementation are shown in FIG. 12. For this case, we prefer to use a completely separate VLC codebook for the first pair of lines, where no previous scan-line's significance is available, with 8 distinct contexts for this case and another 8 contexts for groups found within a non-initial pair of scan-lines.

For the first case, where group g is found in the first pair of scan-lines, group context is formed using the significance of the preceding 4 samples, in scanning order, identified here as σ_(g) ^(p1) through σ_(g) ^(p4), all of which are taken to be 0 if g is the first group in the code-block. The group context for this case is given by

c _(g)=σ_(g) ^(p1)+2σ_(g) ^(p2)+4(σ_(g) ^(p3)|σ_(g) ^(p4))

For all other groups, the significance coding context is formed using the significance of the previous two samples, in scanning order, i.e., σ_(g) ^(p1) and σ_(g) ^(p2), together with the significance of four neighbouring samples on the previous scan-line, identified in FIG. 12 as σ_(g) ⁰ through σ_(g) ³. One of the following simple formulations may then be adopted for the group context

c _(g) ^(unbal)=(σ_(g) ^(p1)|σ_(g) ⁰|σ_(g) ¹)+2σ_(g) ^(p2)+4(σ_(g) ²|σ_(g) ³), or

c _(g) ^(bal)=(σ_(g) ⁰|σ_(g) ¹)+2(σ_(g) ^(p1)|σ_(g) ^(p2))+4(σ_(g) ²|σ_(g) ³)

Both context label definitions are amenable to efficient formation during encoding and decoding, in software and hardware.

Variable Length Coding of Group Significance Patterns

Here we provide specific information about the VLC codes used to encode significance patterns for non-AZC groups and for AZC groups that are identified as significant within the adaptively coded bit-stream.

A separate VLC table is defined for each context c_(g). Each of these has 16 codewords, except when c_(g)=0 (the AZC context), which only has 15 codewords, because the existence of at least one significant sample in the group has already been coded within the adaptively coded bit-stream, as already explained. The codeword length is limited to 6 bits, so that decoding can be achieved using lookup tables with only 64 entries per context.

The VLC tables are essentially defined by the lengths of each codeword, since a suitable set of codewords can always be derived from the set of codeword lengths in each context. Some choices of codewords may allow direct computation of the VLC codes in place of a lookup table.

One very simple construction that allows this is to simply map the significance of each sample in the group to its own codeword bit, except for the AZC context, where the first 2 bits of the codeword identify the index f of the first sample in the group (in scanning order) that is significant, which is followed by 3-f bits that identify the individual significance of each later sample in the group. The codeword lengths for this (reference) choice are shown in Table 2.

TABLE 2 A simple set of VLC codeword lengths, compatible with coding the a run of initial zeros in the AZC context, and assigning an individual bit to each other sample's significance. 0 1 2 3 4 5 6 7 8 9 A B C D E F p: h h h h h h h h h h h h h h h h c_(g) = 0: — 5 4 5 3 5 4 5 2 5 4 5 3 5 4 5 c_(g) > 0: 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4

To generate a good set of VLC codeword lengths, we collect statistics on a large set of natural images, compressed at bit-rates in the range 1 bits/pel to 6 bits/pel, using the well-known Huffman construction to discover optimal lengths, constrained to at most 6 bits per codeword.

TABLE 3 An optimized set of VLC codeword lengths for the 1 × 4 group structure. 0 1 2 3 4 5 6 7 8 9 A B C D E F p: h h h h h h h h h h h h h h h h c_(g) = 0: — 3 3 4 3 5 4 5 3 5 5 5 4 5 4 4 c_(g) = 1: 1 5 5 6 4 6 5 6 3 6 6 6 4 6 5 6 c_(g) = 2: 1 3 4 4 5 6 6 5 5 6 6 6 6 6 6 5 c_(g) = 3: 3 5 5 5 5 5 5 4 4 5 5 4 4 4 4 2 c_(g) = 4: 2 4 4 5 5 5 5 4 4 5 5 5 4 5 4 3 c_(g) = 5: 3 4 5 4 5 5 5 4 4 5 5 4 5 5 4 2 c_(g) = 6: 2 3 5 3 6 5 5 4 5 5 6 5 5 5 5 3 c_(g) = 7: 5 5 6 5 6 6 6 4 6 5 6 4 5 4 4 1

For linear 1×4 groups, the derived codeword lengths are shown in Table 3. These codeword lengths are substantially superior to those of Table 2, yielding typical improvements in the range 0.2 to 0.5 dB in PSNR, at the same bit-rate, across the full range of operating conditions. Note that for linear groups we use only one set of VLC tables, for both the initial line and non-initial lines of the code-block, with just 8 contexts in total. This works because relatively little context information is available to the first line, so not many contexts are required, and their importance is diminished by the fact that the first line typically accounts for only a very small fraction of the code-block samples.

For the 2×2 square group structure, we develop two separate sets of VLC codewords: one for groups found in the first line-pair; and one for groups found in non-initial line-pairs. Optimized codeword lengths are reported in Table 4 and Table 5, where the latter corresponds to the “unbalanced” labels identified above as c_(g) ^(unbal). The use of optimized VLC codewords are even more important to compression performance in the 2×2 group case than they are for 1×4 linear groups. We find that the overall coding efficiency for 2×2 groups is slightly higher than for 1×4 groups when using the respective optimized VLC codewords, while the reverse is true if the trivial codewords of Table 2 are used.

TABLE 4 An optimized set of VLC codeword lengths for 2 × 2 square groups within the initial row of groups in a code-block. 0 1 2 3 4 5 6 7 8 9 A B C D E F p: h h h h h h h h h h h h h h h h c_(g) = 0: — 3 3 5 3 4 5 6 3 6 4 5 3 5 5 4 c_(g) = 1: 1 4 5 5 4 4 6 6 5 6 6 6 5 5 6 4 c_(g) = 2: 1 5 4 5 5 6 6 6 4 6 4 6 5 6 5 4 c_(g) = 3: 2 5 5 4 5 5 6 4 5 6 5 4 5 5 5 2 c_(g) = 4: 1 5 5 5 4 5 6 6 4 6 5 6 5 5 5 4 c_(g) = 5: 3 4 5 5 5 2 5 4 5 5 5 5 5 4 5 3 c_(g) = 6: 3 5 4 5 5 5 5 5 5 5 2 4 5 5 4 3 c_(g) = 7: 5 6 6 5 6 5 6 4 6 6 5 4 5 4 4 1

TABLE 5 An optimized set of VLC codeword lengths for 2 × 2 square groups within non-initial group rows of a code-block, based on context labels c_(g) ^(unbal). 0 1 2 3 4 5 6 7 8 9 A B C D E F p: h h h h h h h h h h h h h h h h c_(g) = 0: — 3 3 5 3 5 6 6 2 6 3 6 4 6 5 6 c_(g) = 1: 1 4 4 5 5 4 6 6 4 6 5 6 5 6 6 5 c_(g) = 2: 1 6 3 6 6 6 6 6 4 6 3 6 6 6 6 6 c_(g) = 3: 2 4 4 4 5 5 5 5 4 5 4 4 5 5 5 3 c_(g) = 4: 1 5 5 6 3 6 6 6 4 6 6 6 4 6 5 5 c_(g) = 5: 2 4 5 5 4 4 5 4 5 5 5 5 5 4 4 3 c_(g) = 6: 2 5 4 5 4 5 5 5 4 5 4 5 4 5 4 3 c_(g) = 7: 5 6 6 5 6 5 6 4 6 6 5 4 5 4 4 1

One might expect that coding efficiency can be improved by using separately optimized VLC codeword tables for DWT subbands with different orientations, or perhaps even different levels in the DWT hierarchy. Indeed this does bring some small benefits, but our experiments suggest that these benefits are typically smaller than 1% of the overall coded data rate, which may not be sufficient to justify the expanded number of tables.

Magnitude Exponents

As mentioned, in bit-plane p, the magnitude of sample X[n] is taken to be

${M_{p}\lbrack n\rbrack} = \left\lfloor \frac{{X{n}}}{2^{p}\Delta} \right\rfloor$

and the sample is considered significant if M_(p)[n]≠0. The “magnitude exponent” E_(p)[n] for the sample in bit-plane p is defined as follows:

E _(p)[n]=min{E∈N|M _(p)[n]−½<2^(E−1)}

where

is the set of natural numbers (non-negative integers). The following table should help explain this definition.

M _(p):0 1 2 3 4 5 8 9 . . . 16 17 . . . 32 . . . 2³⁰+1 . . . 2³¹

E _(p): 0 1 2 3 3 4 4 5 . . . 5 6 . . . 6 . . . 32 . . . 32

Note that the algorithm described here assumes that magnitudes can be represented as 32-bit integers, so that their magnitude should never exceed 2³¹. However, extensions of the algorithm to even higher precisions are easy to derive.

Software based encoders can compute the magnitude exponents of all samples in the code-block ahead of time and store them in memory (1 byte per sample). Note that most CPU's include instructions that can be used to efficiently compute the magnitude exponents.

Magnitude and Sign Coding: Introduction

We turn our attention now to the coding of magnitude and sign information for samples that are known to be significant. Importantly, since a sample is known to be significant, it is sufficient to code the value of M_(p)−1≥0. In this case, we also have magnitude exponent E_(p)−1≥0 and we have

E _(p)=min{E∈

M _(p)−1<2^(E−1)}

That is, the E_(p)−1 is the minimum number of bits required to represent the value of M_(p)−1. Our magnitude exponent definition has been devised precisely in order to make this so. The magnitude exponent depends on the bit-plane p in a non-trivial way, and this is important to the efficient coding of the magnitudes of significant samples. Our coding strategy effectively takes M_(p) to be uniformly distributed over the range from 1 to 2^(E) ^(p) ⁻¹, so that it is sufficient to emit the E_(p)−1 least significant bits of M_(p)−1 to the relevant bit-stream, once the value of E_(p) itself has been established. We also take the sign of each significant sample to be uniformly distributed, so that it is also sufficient to emit the sign bit as a raw binary digit.

Greater care needs to be exercised in coding the value of E_(p). As mentioned earlier, variants of the FAST block coding algorithm that are described in this document can be classified according to whether the coding of magnitude information is consolidated within a single bit-stream, or distributed between the VLC and MagSgn bit-streams, as shown in FIG. 4 (encoder). In particular, distributed variants of the FAST block coder move some of the information required to identify E_(p) to the VLC bit-stream.

In the following sections, we describe first the consolidated coding of exponents and mag-sign bits, using previously decoded magnitude values to condition the coding of subsequent magnitude exponents. Then, Consolidated Magnitude and Sign Coding we describe a distributed magnitude coding method.

Consolidated Magnitude and Sign Coding

The coding of magnitude information for a significant sample at location n is based on a context, which is formed by accumulating the magnitude exponents of its causal neighbours. In the following we drop the subscript p from all magnitudes and magnitude exponents, taking the bit-plane index to be implied.

The method described here is suitable for the raster scanning order of FIG. 7, along with its 1×4 linear group structure. For 2×2 square groups, it is much simpler to use the distributed magnitude coding strategy described in below (Distributed Magnitude and Sign Coding).

For non-initial scan-lines, the magnitude coding context is formed from

E _(sum)[n]=E ^(W)[n]+E ^(NW)[n]+E ^(N)[n]+E ^(NE)[n]

where E^(W)[n] is the magnitude exponent of the neighbour to the left (0 if there is no left neighbour), E^(N)[n] is the magnitude exponent of the neighbour above (0 if there is no previous scan-line), while E^(NW)[n] and E^(NE)[n] correspond to neighbours above and to the left or right of location n, on the previous scan-line (0 if there is no such neighbour). The superscripts W, NW, N and NE are intended to signify compass directions.

For the first line in the code-block, we use

E _(sum)[n]=(2E ^(W)[n]+E ^(WW)[n])

where E^(WW)[n] is the magnitude exponent of the second sample to the left (0 if there is none). These neighbourhood configurations are shown in FIG. 13.

The magnitude coding context is intended to yield an effective predictor κ[n] for the value of E[n]−1. This can be obtained in a variety of ways, amongst which we have experimented with using a family of prediction state machines indexed by a quantized version of E_(sum)M/4. In the end, however, we find that the best trade-off between compression efficiency and computational complexity results from the assignment:

${\kappa\lbrack n\rbrack} = \left\lfloor \frac{{E_{sum}\lbrack n\rbrack} - \kappa_{off}}{4} \right\rfloor$

where the constant κ_(off) is set to 4. The values 3 and 5 have proven to be nearly as effective, but are slightly less efficient to compute.

The magnitude and sign coding can be considered to proceed in two steps, as follows:

U-Step

Here we emit a comma code that represents the unsigned (hence the “U”) prediction residual

u[n]=max{0,E[n]−1−κ[n]}

Specifically, u[n] 0's are emitted to the raw bit-stream, followed by a 1 (the “comma”).

The decoder recovers u[n] from the raw bit-stream by counting zeros until the first 1 occurs. We note that u[n] should never exceed 31 for the case in which the originally coded subband samples were represented using 32-bit integers (after quantization), since then E[n]≤32, as explained above.

R-Step

Here we determine the number of magnitude bits which must be emitted as

m[n]=κ[n]+u[n]−i[n]

where

${i\lbrack n\rbrack} = \left\{ \begin{matrix} 0 & {{{ifu}\lbrack n\rbrack} = 0} \\ 1 & {{{ifu}\lbrack n\rbrack} \neq 0} \end{matrix} \right.$

We emit first the sign of X[n], being 1 if negative and 0 if positive. Then we emit the least significant m[n] bits of the magnitude value M[n].

To explain this procedure, we note that the magnitude Mot a significant sample satisfies

0≤M−1<2^(E−1)

where E−1≥0. If the unsigned prediction residual u>0, then the decoder can be sure that E−1=κ+u and that 2^(E−2)≤M−1<2^(E−1), so the least significant E−2=κ+u−1 bits of M−1 are sufficient to identify its value; the decoder adds back the implicit most significant 1 to recover M−1 from these m bits. If u=0, the decoder knows only that E−1≤κ+u, so that υ≤M−1<2^(κ)

, which is why m=κ+u bits are emitted.

In light of this discussion, i[n] can be recognized as identifying whether or not the sample at location n has an “implicit-1”.

We note that the decoder forms κ[n] and then recovers m[n]=κ[n]+u[n], where u[n] was obtained in the U-step by decoding the comma code. Unlike the encoder, however, in the R-step the decoder must also recover the magnitude exponent E[n]. In the general case, this may require the m[n] magnitude bits to be retrieved from the raw bit-stream, so that the most significant 1 in the binary representation of M[n]−1 can be found. This step might be the critical path that determines the throughput of a hardware-based decoder. This is because the value of E[n] is required to form the next sample's E_(sum) value, which is required in that sample's R-step if the sample is significant.

In summary, the unsigned prediction residual u[n] only partially encodes the value of E[n], given the neighbouring magnitude exponents; to complete the recovery of E[n] when u[n]=0, the magnitude bits themselves are required.

Closely Related Alternatives for Magnitude Coding

The above method for magnitude coding is effectively an exponential Golomb code for M[n]−1, with parameter κ[n], noting that the sign bit is actually interleaved between the comma (unary portion of the code) and the magnitude bits, since this turns out to facilitate efficient software based decoder implementations.

As mentioned, the one minor drawback of this approach is that a decoder cannot generally recover the magnitude exponent E[n] required for forming subsequent magnitude coding contexts until all magnitude bits of the code have been recovered from the raw bit-stream—i.e., until the R-step completes.

Rice Mapping

An alternative strategy is to employ a KM-dependent Rice mapping of the signed prediction residual

S[n]=E[n]−1−κ[n]

The Rice mapping interleaves +ve and −ve values of the prediction residual s, noting that the most negative value is −κ, and the most positive value is 31-κ, so as to produce an unsigned mapped quantity r[n] that can then be encoded directly using a comma code or a fixed Golomb code. The potential advantage of this approach is that a decoder can recover the magnitude exponent immediately, from E[n]=1+K[n]+s[n], without having to wait for the magnitude bits to be imported from the raw bit-stream. That is, magnitude exponents can be propagated to causal neighbours directly from the first step of the decoding procedure, without having to wait for the second step to complete. Despite the small overhead of the Rice unmapping procedure, this is likely to allow hardware solutions to achieve slightly higher throughputs. On the other hand, the approach is somewhat disadvantageous to software deployments, where the Rice mapping/unmapping operations must usually be implemented using lookup tables. Furthermore, experiments show that the compression efficiency of these methods is slightly inferior to the preferred approach documented in the preceding section.

An Alternative Bit Arrangement for Magnitude and Sign Coding

This section presents an alternative arrangement for the bits emitted by the U and R steps to that described above. This alternative arrangement has the same coding efficiency of that of the above arrangement, since it is only a reordering of the emitted bits; in other words, we need exactly the same number of bits for this alternative representation.

Depending on the value of u[n], we identify four cases:

-   -   Case 1: u[n]>κ[n]. In this case, which is summarized in Table 6,         the encoder emits u[n] zeros followed by 1 (the comma), followed         by the sign X[n] of M[n], and then by κ[n]+u[n]−1=E[n]−2 least         significant bits of M[n]−1. This is possible since we know that         2^(E−2)≤M−1<2^(E−1). This is exactly the same code emitted by         Section 0 when u[n]>0.     -   Case 2: κ[n]≥u[n]>0. In this case, the encoder emits u[n]−1         zeros followed by 1 (the comma), and then by a single zero         (denoted by d[n]=0), followed by the sign X[n] of M[n], and then         by κ[n]+u[n]−1=E[n]−2 least significant bits of M[n]−1. See         Table 6.     -   Case 3: u[n]=0, and p[n]≤κ[n], where p[n]=κ[n]−(E[n]−1). In this         case, we have 2^(κ−p−1)≤M−1<2^(κ−p) The encoder emits p[n] zeros         followed by 1 (the comma), and then by a single one (denoted by         d[n]=1), followed by the sign X[n] of M[n], and κ[n]−p         [n]−1=E[n]−2 least significant bits of M[n]−1. See Table 6.     -   Case 4: u[n]=0, and p[n]=κ[n]. In this case E[n]−1=M[n]−1=0. The         encoder emits κ[n] zeros followed by 1 (the comma), and then by         the sign X[n] of M[n]. See Table 6.

TABLE 6 The four cases of the alternative bit arrangement. The table shows the condition for each case, the bits emitted and their arrangement. “NA” means not applicable and indicates that no bits has to be emitted for that field. # of LSB bits from # of Case Condition M[n] − 1 Sign d[n] zeros 1 u[n] > k[n] k[n] + u[n] − 1 X[n] NA 1 u[n] 2 k[n] ≥ u[n] > 0 k[n] + u[n] − 1 X[n] 0 1 u[n] − 1 3 u[n] = 0 & p[n] < k[n] − p[n] − 1 X[n] 1 1 p[n] k[n] 4 u[n] = 0 & p[n] = NA X[n] NA 1 k[n] k[n]

We move our attention to the decoder now. The decoder evaluates κ[n] from the context of the significant sample under consideration. The decoder would then count the number of zeros

[n] until a comma (a one) is found; the number of zeros

[n] can be equal to u[n], u[n]−1, p[n], or

[n]. The decoder would then proceed as follows:

-   -   If         [n]=κ[n]: this is case 4, and decoding can proceed by reading         the sign bit X[n] of M[n], and we have M [n]−1=0.     -   If         [n]>κ[n]: this is case 1, where         [n]=u[n], and decoding can proceed by reading the sign bit X[n]         of M[n], and κ[n]+         [n]−1=E[n]−2 LSBs of M[n]−1 from the bit-stream. The decoder         would then need to add the implicit MSB of M[n]−1; the implicit         MSB was not transmitted because it is known to be 2^(E−2).     -   If         [n]<κ[n]: this can be either case 2 or case 3. The decoder can         identify the case by inspecting the bit after the comma, d[n].         For case 2, we have d[n]=0, and for case 3 we have d[n]=1.         Depending on the case, the decoder would proceed, as follows         -   For case 2 (d[n]=0), where             [n]=u[n]−1, the decoder would then read the sign bit X[n] of             M [n], and κ[n]+             [n]=E[n]−2 LSBs of M [n]−1 from the bit-stream. The decoder             would then need to add the implicit MSB of M[n]−1; the             implicit MSB was not transmitted because it is known to be             2^(E−2).         -   For case 3 (d[n]=1), where             [n]=p[n], the decoder would then read the sign bit X[n] of             M[n], and κ[n]−             [n]−1=E[n]−2 LSBs of M[n]−1 from the bit-stream. The decoder             would then need to add the implicit MSB of M[n]−1; the             implicit MSB was not transmitted because it is known to be             2^(E−2).

TABLE 7 How the decoder can identify the four cases of the alternative bit arrangement of this section. The table shows the conditions for each case, the number of bits to read from the bit-stream, and the existence of an implicit MSB. The # of LSBs that Implicit must be read from MSB at the bit-stream position Case Condition (equal to E[n] − 2) E[n] − 2 1

[n] > κ[n] κ[n] + 

[n] − 1 yes 2

[n] < κ[n] & d[n] = 0 κ[n] + 

[n] yes 3

[n] < κ[n] & d[n] = 1 κ[n] − 

[n] − 1 yes 4

[n] = κ[n] NA no

The advantage of this method is that the exponent E[n] can be calculated immediately after decoding

[n] and, whenever necessary, d[n] while the arrangement above requires counting the number of trailing zeros in M[n]−1, after decoding M[n]−1. Once the decoder knows E[n], it can propagate this information to causal neighbours to commence their decoding, without having to wait for M[n] decoding to finish. A pipelined hardware can benefit from the bit arrangement of this section by evaluating κ for the following sample once it knows the exponent E[n].

Another advantage for hardware implementation is the all the information needed to determine E[n] exists at the bottom of the bit-stream, and therefore sequential processing of bits is possible, which simplifies decoding circuitry.

Software implementation can also benefit from this arrangement. Most modern CPUs employ pipelining, and can hide the latency of some instructions by overlapping them with other instructions. Thus, carefully written code can allow for the overlap of instructions decoding the current sample with instructions decoding the next sample once E[n] becomes available.

This arrangement is applicable to both dual and triple bit-stream variants of the FAST block coder's cleanup pass, since the method is only concerned with coding the magnitude and sign of significant samples.

Line-Causal Contexts

The problem addressed by each of the above alternatives arises from the fact that the context (or predictor) that is used to encode/decode the magnitude of a significant sample depends upon the preceding sample's magnitude exponent, in scanning order.

A simple way to address this problem is to modify the definition of κ[n], so that it depends only upon the magnitudes of samples found in the previous scan-line. For example, the definition of E_(sum)[n] can be replaced by

E _(sum)[n]=E ^(NW)[n]+2E ^(N)[n]+E ^(NE)[n]

Note, however, this approach leaves the magnitudes on the very first scan-line without any predictor at all.

Distributed Magnitude and Sign Coding

In distributed magnitude coding variants of the FAST block coding algorithm, some of the information required to discover the magnitude exponents of significant samples is moved to the VLC bit-stream. As an example, the unary coded unsigned prediction residuals u[n] described in above can readily be moved to the VLC bit-stream, without damaging the important property that the VLC bit-stream can be decoded without reference to the MagSgn bit-stream. The decoded u[n] values cannot immediately be used to recover the magnitude exponents E[n] of the significant samples, since this requires knowledge of earlier magnitude exponents, which may depend on magnitude bits found in the MagSgn bit-stream. However, the ability to decode the u[n] values ahead of time can reduce critical path latencies and increase decoding throughput.

By coupling this approach with line-causal contexts, as described above, it is possible to eliminate all significant inter-sample dependencies associated with magnitude decoding. However, it is important to carefully bound the maximum number of bits that can be moved into the VLC bit-stream, since this affects the overall complexity of both hardware and software encoders and decoders.

We now describe our preferred approach for distributed coding of the magnitudes (and the signs) of significant samples. The approach is suitable for both the raster scanning order of FIG. 7, with its 1×4 group structure, and the line-interleaved scanning order of FIG. 8, with its 2×2 group structure. The approach involves just one unsigned prediction residual u_(g), for each significant group g—i.e., each group with at least one significant sample.

Distributed Mag-Sign Coding for Non-Initial Group Rows

We begin by describing the coding and interpretation of u_(g) for non-initial group rows within the code-block—i.e., non-initial scan-lines with 1×4 groups, or non-initial line-pairs with 2×2 groups. A predictor KA is formed for each significant sample in group g, based on magnitude exponents from the previous scan-line. Here, n indexes the samples within group g, in the scanning order. FIG. 14 identifies the line-causal exponents E_(g) ⁰, E_(g) ¹, E_(g) ² and E_(g) ³ which are used to form the predictors κ_(g)[n] in our preferred method, for both the 1×4 and 2×2 group structures.

The decoder adds u_(g) to κ_(g)[n] to form an upper bound

U _(g)[n]=u _(g)+κ_(g)[n]

for the corresponding magnitude exponent E_(g)[n] minus 1. That is,

E _(g)[n]−1≤U _(g)[n]

Moreover, this bound is required to be tight in the case where only one sample in the group is significant and u_(g)>0, which is the condition under which the location of the most significant 1 in the binary representation of M_(g)[n]−1 is implicit. Specifically, we define the “implicit-1” condition for group g as

$i_{g} = \left\{ \begin{matrix} 0 & {{{if}\mspace{14mu} u_{g}} = {{0\mspace{14mu}{or}\mspace{14mu}\rho_{g}} \notin \left\{ {1,2,4,8} \right\}}} \\ 1 & {{{{if}\mspace{14mu} u_{g}} \neq {0\mspace{14mu}{and}\mspace{14mu}\rho_{g}}} \in \left\{ {1,2,4,8} \right\}} \end{matrix} \right.$

and the number of emitted magnitude bits for each significant sample in group g to be

m _(g)[n]=U _(g)[n]−i _(g)

The MagSgn bit-stream is formed by visiting each significant sample in scanning order, emitting first the sign bit and then the m_(g)[n] least significant bits of M_(g) [n]−1.

Decoding for a row of groups involves three steps. First, the unsigned prediction residuals u_(g) are decoded while decoding significance patterns. Second, the predictors κ_(g)[n] are determined, using only the significance patterns ρ_(g) and decoded magnitudes from the previous scan-line, during which process the decoder uses u_(g) to discover m_(g)[n] and i_(g). Finally, the sign and magnitude LSBs for M_(g)[n]−1 are unpacked from the MagSgn bit-stream for each significant sample, re-inserting any implicit-1 i_(g).

Although these three steps are inter-dependent, they are nonetheless substantially decoupled. For example, the first step may be performed for all groups in the code-block, before the other steps are performed for any group; alternatively, the first step may be performed immediately before the second, on a group by group basis. The second step may be performed for a whole row of groups before the third step is performed for any of these groups, but again this is not necessary. In general, software implementations tend to benefit from the more distributed approach, where each step is performed on a large number of groups before moving to the second step, since this facilitates the exploitation of vector instructions and improves register utilization. By contrast, hardware implementations are likely to benefit from a less distributed strategy, since this reduces the need for memory resources to preserve intermediate state.

Even though the method is described here in terms of separate VLC and MagSgn bit-streams (i.e., for triple bit-stream variants of the FAST block coder), the same strategy may be used with dual bit-stream variants, where VLC bits and MagSgn bits are interleaved on the basis of a row of groups (line interleaving for linear groups and line-pair interleaving for square groups).

In general, each significant sample in group g may have a different predictor κ_(g)[n], which can be derived from the line-causal exponents E_(g) ⁰, E_(g) ¹, E_(g) ² and E_(g) ³, together with the significance pattern ρ_(g) associated with group g.

For both 1×4 linear groups and 2×2 square groups, a simple and effective method for assigning predictors is as follows:

$P_{g} = \left\{ {{\begin{matrix} 0 & {{{if}\mspace{14mu}\rho_{g}} \in \left\{ {1,2,4,8} \right\}} \\ {{\max\left\{ {E_{g}^{0},E_{g}^{1},E_{g}^{2},E_{g}^{3},1} \right\}} - 1} & {{{if}\mspace{14mu}\rho_{g}} \notin \left\{ {1,2,4,8} \right\}} \end{matrix}Z_{g}} = \left\{ {{\begin{matrix} 0 & {{{if}\mspace{14mu} P_{g}} = 0} \\ 1 & {{{if}\mspace{14mu} P_{g}} > 0} \end{matrix}{\kappa_{g}\lbrack n\rbrack}} = {\kappa_{g} = {P_{g} - Z_{g}}}} \right.} \right.$

Here, P_(g) can be understood as an initial predicted upper bound for the offset magnitude exponents E_(g)[n]−1 of each significant sample in group g. Z_(g) is an offset which allows the unsigned prediction residual u_(g) to effectively represent residuals as small as −1 if P_(g)>0. That is, the bound U_(g)[n] that the decoder derives for E_(g)[n]−1 is actually equal to P_(g) (u_(g)−Z_(g)). The choice P_(g)=0 when only one sample in group g is significant turns out to be rather important.

The strategy described above involves the generation of a common predictor κ_(g) for all significant samples in group g; however, it is possible to derive more effective location-specific predictors, based on the magnitude information from previous group rows, which is fully available at both encoder and decoder, well before the point at which the predictor for a group needs to be formed. It is also possible to use the significance information for all samples in a group, along with its causal neighbours (in scanning order) in order to optimize the prediction performance.

We turn our attention now to VLC codes for the unsigned predictor u_(g). While a unary code (a.k.a. comma code) may be employed, the maximum codeword length in this case could be on the order of 32 for the highest precisions considered in this document; providing for such long codewords adversely impacts the efficiency of both software and hardware implementations. Instead, we prefer the so-called “u-code” in Table 8. The u-code starts out as a comma code, with u=0, u=1 and u=2 represented using the codewords “1”, “01” and “001”, respectively. The codewords for u=3 and u=4 involve the prefix “0001”, followed by the least significant bit of u−3. All larger values of u turn out to be extremely unlikely, so they are assigned a common 4-bit prefix “0000”, which is followed by the 5 LSBs of u−5. This u-code is sufficient for representing subband samples with up to 36 bits of precision.

TABLE 8 u-code used for coding unsigned residuals u_(g), for non-initial group rows. u prefix Suffix l_(p)(u) l_(s)(u) l_(p)(u) + l_(s)(u)  0 “1” — 1 0 1  1 “01” — 2 0 2  2 “001” — 3 0 3  3 “0001” (u − 3) 4 1 5  4 “0001” (u − 3) 4 1 5  5 “0000” (u − 5) 4 5 9  6 “0000” (u − 5) 4 5 9 . . . . . . . . . . . . . . . . . . 36 “0000” (u − 5) 4 5 9 Here, l_(p) and l_(s) denote the prefix and suffix lengths, with l_(p) + l_(s) the overall codeword length, but note that the prefix and suffix bits are actually interleaved on a group-pair basis.

It is worth noting that the shortest codeword here is assigned to the event u_(g)=0, which corresponds to U_(g)[n]=P_(g)−Z_(g). When P

>0, this shortest codeword is thus assigned to the choice U_(N)[n]=P_(N)−1. One might expect that the most likely event would be U_(N)[n]=P_(N), but this is not typically the case, in part because smaller sample exponents are a-priori much more likely than larger sample exponents. It turns out that in the specific case where all samples in a group are significant (i.e., ρ_(g)=15), the event U_(N)[n]=P_(N) is actually more likely, while for all other significance patterns, U_(N)[n]=P_(N)−Z_(g) is the most likely outcome. This can be exploited, if desired, by conditionally exchanging the codewords for u_(g)=0 with u_(g)=1 when ρ_(N)=15. That is, the encoder transforms u_(g) to 1−u_(g) whenever ρ_(g)=15 and u_(g)≤1; this transformation is its own inverse, so the decoder does the same thing. Our experiments suggest that the benefit of this small change is a reduction in coded size by around 0.25%, which might not be sufficient to justify the complexity of introducing the conditional exchange procedure.

Pair-Wise Interleaving of Significance Bits and U-Code Bits

It turns out to be beneficial, especially for software implementations, to interleave the prefix and suffix components of the u-code across a pair of groups. Specifically, the VLC bit-stream is formed by emitting first the (possibly empty) significance VLC codewords associated with a pair of groups, then the u-code prefix for each significant group in the pair, and finally any u-code suffix for each significant group in the pair. For software encoders, this allows a modest lookup table to be used to generate the complete u-code for a pair of groups at once. For software decoders, a small lookup table is sufficient to decode the u-code prefix for a pair of quads at once, allowing the combined codeword length and suffix locations to be determined very efficiently. Each row of groups is extended, if necessary, to a whole number of group pairs, by adding an extra group that has no significance VLC codeword or AZC symbol and is always insignificant, so that it also has no u-code component.

Distributed Mag-Sign Coding for the Initial Group Row

For the initial row of groups within a code-block, no magnitude exponents are available from a previous scan-line. This case can always be handled using the method developed above, but with E_(g) ⁰, E_(g) ¹, E_(g) ² and E_(g) ³ all taken to be 0.

However, since this case may be important in low latency applications, where the code-block height is usually small, we prefer to employ an alternate mechanism for coding the bounds U_(g) involving a form of horizontal prediction. As before, U_(g) is any bound such that the magnitude exponents of all significant samples in group g satisfy

E _(g)[n]−1≤U _(g)

except that the bound must be tight under the “implicit-1” condition, which is described below.

The alternate mechanism developed here again involves predictors and unsigned residuals u_(g), but prediction is formed relative to a base value B_(g), which is adapted from group to group. Specifically,

$U_{g} = \left\{ {{\begin{matrix} 0 & {{{{if}\mspace{14mu}\rho_{g}} = 0}\mspace{76mu}} \\ {B_{g} + u_{g} - 3} & {{{{if}\mspace{14mu}\rho_{g}} \neq 0},{where}} \end{matrix}B_{g}} = \left\{ \begin{matrix} 0 & {{{{{if}\mspace{14mu}\rho_{g}} = 0},{else}}\mspace{200mu}} \\ 1 & {{{{if}\mspace{14mu} g} = {{0\mspace{14mu}{or}\mspace{14mu}\rho_{g}} \in \left\{ {1,2,4,8} \right\}}},{else}} \\ {\min\left\{ {3,{U_{g - 1} + 1}} \right\}} & {{otherwise}\mspace{256mu}} \end{matrix} \right.} \right.$

For a collection of consecutive groups with more than one significant sample, it is possible to understand the unsigned residuals u_(g) as the offset (by 2) difference between consecutive values of U_(g), since in this case U_(g)=U_(g−1)+(u_(g)−2). Evidently, some values for u_(g) should not be admissible, and this is reflected in the code for u_(g), which depends on the value of B_(g), as described below. For a group with only one significant sample, the relations above force B_(g) to 1, so that U_(g)=u_(g)−2 has no dependence on previous groups; as we shall see, the B-dependent code for u_(g) cannot represent values smaller than 2 in this case. The special value B_(g)=0 is not strictly important, since it corresponds to an insignificant group, for which no u_(g) value is coded or used; however, this special value can be used to facilitate efficient implementations that are based on lookup tables.

Before describing the B-dependent VLC code for u_(g), we briefly discuss the determination of the “implicit-1” condition, which is associated with the i_(g) flag; this flag is combined with U_(g) to determine the number of magnitude bits m_(g)[n] that are emitted for each significant sample in group g. The implicit-1 condition can occur only when there is exactly one significant sample in group g, but this is very common condition in practice. In this case, as already mentioned, the relations above yield U_(g)=u_(g)−2 and u_(g) is necessarily no smaller than 2. The implicit-1 condition occurs when u_(g) exceeds this minimum value of 2. That is,

$i_{g} = \left\{ \begin{matrix} 0 & {{{{if}\mspace{14mu} u_{g}} = {{0\mspace{14mu}{or}\mspace{14mu}\rho_{g}} \notin \left\{ {1,2,4,8} \right\}}}\mspace{14mu}} \\ 1 & {{{{if}\mspace{14mu} u_{g}} \neq {0\mspace{14mu}{and}\mspace{14mu}\rho_{g}}} \in \left\{ {1,2,4,8} \right\}} \end{matrix} \right.$

As for non-initial group rows, the number of emitted magnitude bits for each significant sample in group g is given by

m _(g)[n]=U _(g)[n]−i _(g)

and the MagSgn bit-stream is formed by visiting each significant sample in scanning order, emitting first the sign bit and then the m_(g)[n] least significant bits of M_(g)[n]−1.

To encode u_(g), we employ the B-dependent variable length code (or “Bu-code”) defined by Table 9. The code is based on the u-code of Table 8, having the same maximum codeword length of 9 bits, even with very high precision subband samples. Noting that u_(g)−2 plays the role of a signed prediction residual, the u-code is essentially being applied to the absolute value of this signed residual |u_(g)−2|, except that when |u_(g)−2|<B_(g), a sign bit is appended to the 2- or 3-bit prefix, to identify whether u_(g)−2 is positive of negative. Since the prefix of the codeword never exceeds 4 bits in length, efficient LUT-based decoding strategies can be developed, indexed by the 2-bit B value, together with the 4-bit codeword prefix, returning the prefix length, suffix length, U_(g) bound and the next group's B value, which need only be modified if the next group has fewer than 2 significant samples.

As for non-initial group rows, the significance VLC codewords and Bu-code bits are interleaved over a pair of groups. As before, the significance bits for each group in the pair appear first, followed by the Bu-code prefix for each significant group in the pair, and finally any Bu-code suffix for each significant group in the pair.

TABLE 9 Bu-code used for coding unsigned residuals u_(g), within the initial row of groups in a code-block. Here, l_(p) and l_(s) denote the prefix and suffix lengths, with l_(p) + l_(s) the overall codeword length, but note that the prefix and suffix bits are actually interleaved on a group-pair basis. u − 2 B prefix Suffix l_(p)(u, B) l_(s)(u, B) l_(p)(u, B) + l_(s)(u, B) — 0 — — 0 0 0 −2  3 “0011” — 4 0 4 −1  2, 3  “011” — 3 0 3 0 1, 2, 3   “1” — 1 0 1 1 2, 3  “010” — 3 0 3 1 1  “01” — 2 0 2 2 3 “0010” — 4 0 4 2 1, 2  “001” — 3 0 3 3 1, 2, 3 “0001” (u − 5) 4 1 5 4 1, 2, 3 “0001” (u − 5) 4 1 5 5 1, 2, 3 “0000” (u − 7) 4 5 9 . . . . . . . . . . . . . . . . . . . . . 36  1, 2, 3 “0000” (u − 7) 4 5 9

Encoding with Post-Compression R-D Optimization

Post-Compression Rate-Distortion Optimization (PCRD-opt) is a valuable feature of the JPEG2000 algorithm, allowing one or more target compressed bit-rates to be achieved simply by truncating the code-block bit-streams that have already been generated. Finding optimal truncation points is relatively straightforward, given a set of distortion estimates (or measurements) for each truncation point.

The PCRD-opt approach is effective because the JPEG2000 block coder produces a finely embedded bit-stream, offering numerous truncation points (3 per bit-plane), most of which typically lie on the convex hull of the code-block's operational rate-distortion characteristic.

Using PCRD-Opt with the FAST Block Coder

While the FAST block coding algorithm described above is not strictly embedded, it does provide a sufficient level of embedding to allow deployment of a PCRD-opt based rate control methodology. There are still 3 coding passes per bit-plane, whose rate-distortion properties turn out to be very similar to those of the standard JPEG2000 block coder. In experiments with typical photographic imagery, we find that applying an optimal truncation algorithm to the set of FAST block coding passes shown in FIG. 1 yields similar compression efficiency as that achieved with the standard JPEG2000 block coder³. ³ This observation is true for the case where the standard JPEG2000 block coding algorithm operates in the all-BYPASS mode, where all SigProp and MagRef coding passes emit raw bits and adaptive coding is used only in the Cleanup passes.

Of course, after truncating the set of coding passes generated by a FAST block coder, only the last surviving Cleanup pass is emitted to the codestream, along with the surviving SigProp and MagRef passes that follow it, if there are any. This is because each of the FAST block coder's Cleanup passes completely subsumes all preceding coding passes.

One could argue that any non-embedded block coding algorithm could be used with the PCRD-opt algorithm, by arranging for the encoder to compress the content at a larger number of different qualities (different quantization step sizes) and then eventually discarding all but one of the compressed versions of each code-block. The difference between such an approach and that proposed here, however, is that the encoder needs at most to produce one Cleanup coding pass per bit-plane, relying upon the SigProp and MagRef coding passes to effectively interpolate the operational rate-distortion characteristic with extremely low computational effort.

Selective Generation of Coding Passes

Advanced implementations of the PCRD-opt methodology for JPEG2000 already make use of predictive strategies to avoid generating many coding passes that are likely to lie beyond the optimal truncation points that will later be found by the PCRD-opt rate control stage. For the FAST block coder, additional strategies can be used to avoid generating coding passes which are likely to be subsumed by a later Cleanup pass that is retained by the PCRD-opt truncation points. That is, predictive strategies can be used to determine both the last coding pass that is worth generating and the first (coarsest) bit-plane from which to start generating coding passes, as suggested by FIG. 1.

Apart from transcoding applications, where rate control is not normally required, the most important applications for the FAST block coder described in this document involve video, since such applications involve very high data rates that can be challenging for the standard JPEG2000 algorithm.

Existing strategies for predicting final coding passes that are not worth generating in JPEG2000 implementations take advantage of the fact that the distortion-length slope thresholds employed by the PCRD-opt algorithm usually change only slowly from frame to frame, so the block encoder can stop generating coding passes as soon as the distortion-length slope threshold associated with coding passes that it has generated becomes smaller than the distortion-length slope threshold selected by the PCRD-opt algorithm in a previous frame, or the smallest such threshold selected in a defined set of previously generated frames. This strategy can be adopted directly with the FAST block coding algorithm, limiting the generation of coding passes that are likely to be discarded by the PCRD-opt rate control stage.

The sub-sections which follow are primarily concerned with the second issue—i.e., predicting the first/coarsest coding pass that needs to be generated by the FAST block encoder. For this purpose, it is again possible to draw upon observations from the compression of earlier frames.

It is also possible to supplement this information with statistics derived from subband samples, while they are being assembled into code-blocks. Before describing these methods, we make the following observations:

-   -   1. Discarding coarse bit-planes during the encoding process is         more “risky” than discarding fine coding passes that we do not         expect to survive the PCRD-opt stage. If the first generated         bit-plane for a code-block results in the generation of too many         bits, the PCRD-opt stage may not be able to include any content         for the code-block at all. Thus, the worst case distortion         impact associated with the decision to discard coarser         bit-planes is much larger than that associated with discarding         finer bit-planes.     -   2. Coarser bit-planes generally consume less computational         resources than finer bit-planes, at least within software         implementations, so it is advisable for an implementation to err         on the side of generating more coarse bit-planes than it needs,         rather than more fine bit-planes than it needs. In fact, even         when no coarse bit-planes are skipped at all, the FAST block         encoder can still be much faster than JPEG2000.     -   3. High throughput hardware implementations may need to fix the         total number of coding passes that will be generated for any         given code-block, in a deterministic way. This provides a         greater challenge than software environments, where adaptive         algorithms are more easily implemented.     -   4. Applications that require constant bit-rate compressed data         streams with low end-to-end latency are the most challenging for         algorithms that selectively generate coding passes or         bit-planes. The likelihood that a poor decision results in large         distortion is greatly increased if the PCRD-opt algorithm is         forced to comply with a tight bit budget, especially where this         is done regularly on small sets of code-blocks.

Despite the difficulties identified above, it is possible to develop effective algorithms that allow high throughput encoding, even in hardware, with good compression performance.

A Length-Based Bit-Plane/Coding Pass Selection Algorithm

In this section we describe a first algorithm that can be used to skip the generation of coarse bit-planes during the block encoding process. This algorithm relies upon coded length estimates and measurements to mitigate the risk that entire code-blocks must be discarded by the PCRD-opt algorithm. The method is suitable for situations in which at least two bit-planes are encoded, but preferably three or more, and they are encoded sequentially rather than concurrently. This allows the encoded length of each encoded bit-plane to guide the selection of subsequent bit-planes to encode. These attributes may render the algorithm more suitable for software implementations than hardware.

We assume that a sequence of frames from a video sequence is being compressed. For simplicity of description, we also assume that the PCRD-opt algorithm is being used to select coding passes for each frame's codestream subject to a constraint L_(max) on each frame's compressed size. That is, all frames are taken to have the same length constraint. It is not hard to see how the method described below can be adapted to length constraints that might differ from frame to frame. The method may also be adapted to low latency applications, where the length constraint is applied to smaller collections of code-blocks that represent only a fraction of the frame.

As the PCRD-opt algorithm is invoked on each frame k, selecting a set of coding passes (one Cleanup, optionally followed by SigProp and perhaps a MagRef pass) to include in the frame's codestream, we record two types of information for the frame. First, we record the total number of bytes L_(β) ^(k), contributed to frame k's codestream by each subband β. These can be converted to a set of “suggested” subband data rates R_(β) ^(k), according to

$R_{\beta}^{k} = {{\frac{L_{\beta}^{k}}{\Sigma_{b \in B}N_{b}} \cdot \frac{L_{\max}}{\Sigma_{i}L_{i}^{k}}}\mspace{14mu}{bytes}\text{/}{samples}}$

where N_(b) is the number of samples in a code-block b, so that Σ_(b∈β)N_(b) is just the total number of samples in subband β.

Now let L_(p,b) ^(k) be the length (in bytes) associated with the Cleanup pass belonging to bit-plane p within code-block b of frame k and consider a subsequent (being generated) frame, k_(gen). So long as each code-block b in subband β has at least one generated Cleanup pass, for which

$\begin{matrix} {L_{p,b}^{k_{gen}} \leq {R_{\beta}^{k}N_{b}}} & ({RB}) \end{matrix}$

then we can be sure that the PCRD-opt algorithm will be able to generate a codestream for frame k_(gen) whose overall length is no larger than L_(max). Actually, even without this constraint it is always possible for the PCRD-opt algorithm to entirely discard one or more code-blocks in order to satisfy the length constraint L_(max). However, this may incur a large degradation in quality, if code-blocks are being discarded only because the coding passes associated with sufficiently coarse bit-planes were not generated by the block encoder.

The second type of information to be recorded during the generation of frame k's codestream is a coarsest bit-plane index p_(max,γ) ^(k), associated with each of a collection of code-block groups γ. One grouping approach is to identify each code-block group γ, with a distinct JPEG2000 precinct, although it can be preferable to further differentiate (via distinct groups) the distinct subband orientations (e.g., HH, LH, HL) of the code-blocks within a precinct.

It can also be desirable to use overlapping groups of code-blocks. At one extreme, a group consists of a single code-block, while at the other extreme, all subbands from a given resolution level in the wavelet decomposition of an image component might be considered to constitute a single group. In any event, p_(max,γ) ^(k) is the coarsest bit-plane associated with any Cleanup pass from any code-block in group γ that the PCRD-opt algorithm chooses to embed in the codestream for frame k. Additionally, let γ_(b) be the “natural” group for code-block b, which is just the group to which code-block b belongs, unless there are multiple such groups (overlapping groups), in which case γ_(b) is the group whose geometric centre most closely coincides with that of code-block b.

Using this information in a subsequent (i.e., being generated) frame, k_(gen), the block encoder for code-block b starts by generating its first Cleanup coding pass for bit-plane

p=min{p _(msb,b) ^(k) ^(gen) ,p _(maxγ) _(b) ^(k)+Δ_(adj)}, yielding coded length L _(p,b) ^(k) ^(gen)

Here, p_(msb,b) ^(k) ^(gen) is the coarsest (most significant) bit-plane for which any sample in code-block b is significant in frame k_(gen). Essentially, the block encoder interprets the coarsest bit-plane for which any coding pass was emitted in the earlier frame k, within a neighbourhood (the group γ_(b)) of code-block b, as an initial estimate for the coarsest bit-plane that it needs to consider in frame k_(gen). The offset Δ_(adj)≥0 must at least sometimes be non-zero so as to ensure that the algorithm does not become trapped (over time) in a sub-optimal state.

Importantly, the block encoder compares the length L_(p,b) ^(k) ^(gen) of this first generated Cleanup pass with the suggested subband data rate, as given by equation (RB) above. If L_(p,b) ^(k) ^(gen) exceeds the bound R_(β) ^(k)N_(b) and p<p_(msb,b) ^(k) ^(gen) , the bit-plane index p is increased by 1 and a new Cleanup pass is encoded, having the (generally smaller) length L_(p,b) ^(k) ^(gen) . This process is repeated until the coarsest generated Cleanup pass satisfies the suggested rate bound or no coarser significant bit-planes exist. Once this condition is reached, the encoder may generate content for even coarser bit-planes to provide the PCRD-opt algorithm with a greater diversity of content, subject to available computational resources.

Both the complexity and performance of this method depend on the Δ_(adj) value. In software implementations that do not have tight latency constraint, the value of Δ_(adj) can be adapted from frame to frame in order to achieve a required average throughput.

A Coding Pass Selection Algorithm for Low Latency Applications

In this section we describe an algorithm for generating a prescribed maximum number of coding passes in any given code-block. The algorithm is suitable for high performance hardware implementation, as well as software, since the bit-planes to be processed are determined up front, without relying upon a sequential encoding process. Unlike the preceding section, which considered only the determination of a coarsest bit-plane to process, here we are concerned with the determination of the full set of coding passes to be processed for a given code-block.

The algorithm described here is suitable for low latency applications, where the PCRD-opt algorithm is exercised regularly on collections of code-blocks that might represent only a small part of a complete video frame; we use the term “flush-set” for such a collection of code-blocks. Again, we rely upon the fact that a sequence of video frames is being compressed, so that outcomes from the PCRD-opt algorithm in a previous frame can be used to guide the selection of coding passes in a subsequent frame. The selection of coding passes for each code-block is based on distortion-length slope information, since coded lengths are not available up front.

In the following discussion, we first briefly review the PCRD-opt process for selecting an appropriate coding pass from a set of coding passes generated for each code-block. This is essentially a review of the PCRD-opt algorithm, which is not specific to the problem of limiting the set of coding passes actually generated in the first place.

Let L_(γ) ^(k) ^(gen) represent the length constraint that applies to a single flush-set (group of code-blocks) γ in the current frame being generated. Let T_(γ) ^(k) ^(gen) represent a distortion-length slope threshold for the flush-set γ. The slope threshold T_(γ) ^(k) ^(gen) is used to select appropriate coding passes from each code-block in accordance with distortion-length performance. We use the notation S_(cp,b) ^(k) ^(gen) to refer to the distortion-length slope resulting from choosing coding pass cp for a code-block b. This is the ratio between distortion reduction and coded length increase, measured between coding passes which lie on the convex hull of the code-block's operational distortion-length characteristic; these slope values necessarily decrease monotonically as the coding passes progress from coarse bit-planes to the finest bit-plane. The PCRD-opt algorithm identifies the last coding pass cp, if any, to be included from code-block b in the generated flush-set. Specifically, cp is the last (finest) coding pass, if any, for which S_(cp,b) ^(k) ^(gen) ≥T_(γ) ^(k) ^(gen) .

Let L_(cp,b) ^(k) ^(gen) represent the length of a code-block b for the selected coding pass cp which adheres to the distortion-length slope objective. The summation of all length contributions from each code-block in the flush-set {circumflex over (L)}_(γ) ^(k) ^(gen) provides an initial length value which can then be compared to the flush-set target length L_(γ) ^(k) ^(gen) . If the initial length {circumflex over (L)}_(γ) ^(k) ^(gen) exceeds the target length L_(γ) ^(k) ^(gen) then T_(γ) ^(k) ^(gen) can be increased appropriately and the coding pass selection process repeated for the flush-set. A larger value for T_(γ) ^(k) ^(gen) means coarser bit-planes will potentially be selected from each code-block, thereby reducing the contribution to total length. The slope threshold T_(γ) ^(k) ^(gen) can be repeatedly increased until total flush-set length {circumflex over (L)}_(γ) ^(k) ^(gen) no longer exceeds the target L_(γ) ^(k) ^(gen) . In a similar manner, if initially {circumflex over (L)}_(γ) ^(k) ^(gen) is lower than the target length L_(γ) ^(k) ^(gen) then the slope threshold T_(γ) ^(k) ^(gen) can be decreased and the coding pass finer selection process repeated. A lower value for T_(γ) ^(k) ^(gen) implies finer bit-planes will potentially be selected from each code-block, increasing the contribution to total length.

We now describe the process followed in generating a limited set of coding passes for each code-block. This relies upon the observation that the rate-distortion characteristics of code-blocks are relatively stable from frame to frame. Therefore the coding of the current code-block b can be guided by attributes of the corresponding code-block {circumflex over (b)} in the previous frame. The preferred embodiment makes use of a number of stored attributes of {circumflex over (b)}; these include the bit-plane p_({circumflex over (b)}) ^(k) and the associated coding pass cp_(b) ^(k) (ie Cleanup, SigProp or MagRef) that was last included in the bit-stream. We find that in many instances, p_({circumflex over (b)}) ^(k) is a good estimate for the bit-plane of the current code-block at which coding should be performed. Therefore the Cleanup pass at bit-plane p_({circumflex over (b)}) ^(k) and associated SigProp and MagRef passes are always generated for the current code-block. To allow the rate-control algorithm to adapt to changes in content from frame to frame, it is important to also consider generating coding passes for coarser and finer bit-planes with respect to the predicted anchor p_({circumflex over (b)}) ^(k). In the preferred embodiment, coding passes for bit-planes p_({circumflex over (b)}) ^(k)+1 and p_({circumflex over (b)}) ^(k)−1 are considered, depending on the status of the corresponding code-block {circumflex over (b)} in the previous frame.

If p_({circumflex over (b)}) ^(k) equates to the coarsest bit-plane that was generated for the previous code-block {circumflex over (b)}; and the corresponding last coding pass that was included cp_({circumflex over (b)}) ^(k) is a Cleanup pass then an “initial coding pass” flag is set to 1 (INITIAL_CP=1). This indicates that a coarser bit-plane may have been useful but was not available to the prior code-block {circumflex over (b)}. The current code-block therefore considers the coarser bit-plane p_({circumflex over (b)}) ^(k)+1, generating the Cleanup pass and optionally the associated SigProp and MagRef passes. The inclusion of the SigProp and MagRef can be made dependent on a user defined upper limit on the total number of coding passes that are to be generated.

If p_({circumflex over (b)}) ^(k) equates to the finest bit-plane that was generated for the previous code-block {circumflex over (b)}, and the corresponding last coding pass that was included cp_({circumflex over (b)}) ^(k) is a MagRef pass then a “final coding pass” flag is set to 1 (FINAL_CP=1). This indicates that a finer bit-plane may have been beneficial but was not generated for the prior code-block {circumflex over (b)}. To further validate the benefit of considering a finer bit-plane, the distortion-length slope S_(cp,{circumflex over (b)}) ^(k) corresponding to coding pass cp_({circumflex over (b)}) ^(k) is compared with the flush-set threshold T_({circumflex over (γ)}) ^(k); where {circumflex over (γ)} denotes the flush-set which includes the prior code-block {circumflex over (b)}. If there is only a small difference between S_(cp,{circumflex over (b)}) ^(k) and T_({circumflex over (γ)}) ^(k) then this implies that the generated coding pass cp_({circumflex over (b)}) ^(k) was adequate and there may be little gain in considering a finer bit-plane for current code-block. However, if the “final coding pass” flag is set to 1 (i.e. FINAL_CP=1) and the slope value S_(cp,{circumflex over (b)}) ^(k) is substantially larger than the flush-set threshold T_({circumflex over (γ)}) ^(k) then the finer bit plane p_({circumflex over (b)}) ^(k)−1 is considered for the current code-block. The Cleanup pass and optionally the associated SigProp and MagRef passes are then generated for bit plane p_({circumflex over (b)}) ^(k)−1. Once again the generation of the SigProp and MagRef passes can be made dependent on a user defined upper limit on the total number of coding passes that are to be generated.

Another important code-block attribute that is monitored from frame to frame is the number of missing MSB for each code-block. Large differences in missing MSB between the prior code-block {circumflex over (b)} and current block b can be used as crude measure of a rapid change in the complexity of the code-block. In the preferred embodiment, if the number of missing MSB for the current block b is greater than that of the prior block {circumflex over (b)} then coding passes for the finer bit plane p_({circumflex over (b)}) ^(k)−1 are generated regardless of the FINAL_CP flag or the values for S_(cp,{circumflex over (b)}) ^(k) and T_({circumflex over (γ)}) ^(k); since these measures are not considered valid due to the rapid change in code-block complexity. The impact that the number of missing MSB can have on coding pass generation can be made selective depending upon sub-band; for example in the preferred embodiment for the LL sub-band the number of missing MSB is not considered as a dependable measure of change in code-block complexity.

For each of the generated coding passes, a corresponding distortion-length slope is calculated and stored. These slope values are then used to select the coding passes that will be finally included into the bit-stream. The rate-distortion optimal coding pass selection strategy, based on distortion-length slopes, was described earlier in this section.

In some implementations, it is not actually necessary to store distortion-length slopes and thresholds from a previous frame, because the algorithm described above relies only upon whether the difference between S_(cp,{circumflex over (b)}) ^(k) and T_({circumflex over (γ)}) ^(k) is small.

Complexity-Aware Coding Pass Selection Algorithm

The method described above works well in practice, even when every code-block is constrained to process no more than 2 consecutive bit-planes, except where large changes in complexity are experienced between consecutive frames in the video sequence. In particular, if a frame (or region of a frame) exhibits very low complexity (e.g., little texture, few edges, etc.), the PCRD-opt algorithm tends to select the finest bit-plane available for each relevant code-block. Over a sequence of frames, this rapidly moves the operating point to one that represents very fine quantization of the content. If the complexity then suddenly increases, this fine operating point produces far too many bits and the PCRD-opt algorithm is forced to discard whole code-blocks, resulting in a large distortion penalty. The condition disappears rapidly, with high performance restored typically within 2 or 3 frames from a large complexity transient, which might well be sufficient to avoid perceptible distortions, but it is desirable to take steps to reduce or eliminate such transients. In this section, we describe a way to measure both global and local complexity, which can be used to enhance the coding pass selection algorithm described above.

In memory/latency constrained environments, lines of subband samples produced by the wavelet transform are pushed incrementally to a collector, which assembles them into code-blocks and then launches the block encoding process at the earliest convenience. During this process, the subband samples can be analysed to assess coding complexity. Subband samples from horizontally adjacent code-blocks in the same subband and from other subbands at the same level in the wavelet hierarchy are produced at similar times, so their complexity can be combined to form more global estimates. Similarly, complexity information can be combined from subbands belonging to different image components (e.g., colour components), where the combined subbands have the same vertical resolution. Even more global estimates can be formed by accumulating complexity estimates across different resolutions, but this can only be done selectively in memory or latency constrained applications.

The method described here begins with the accumulation of absolute subband samples within individual code-blocks, as a local measure of complexity. Specifically, for a code-block b within subband β, the local complexity measure may be expressed as

${\mathcal{C}_{\beta}\lbrack b\rbrack} \cong {\log_{2}\left( {\frac{1}{{\mathcal{N}_{b}} \cdot \Delta_{b}}{\sum\limits_{n \in \mathcal{N}_{b}}\left( {{{X_{b}\lbrack n\rbrack}} + \Delta_{\beta}} \right)}} \right)}$

Here, Δ_(β) is the quantization step size,

denotes the set of sample locations that lie within code-block b, and ∥

∥ is the code-block area. We write rather than strict equality, since in many applications the log₂(x) operation will be approximated rather than computed exactly. For example, some or all of the bits in a floating point representation for x may be re-interpreted as a fixed-point approximation of log₂(x). Efficient computation of C_(β)[b] might involve moving the division by ∥

∥·Δ_(β) outside the logarithm, where it becomes a fixed offset.

As mentioned, the accumulation represented by the above equation would typically be performed incrementally, as subband samples become available from the wavelet transform and perhaps other transformation processes, such as a colour transform. Once a complete row of code-blocks has been assembled for encoding, the normalization and log operations associated with C_(β)[b] may be performed for each code-block in the row. At the same time, the local complexity estimates may be combined into more global estimates as follows:

$\mathcal{G}_{v} = \frac{\Sigma_{{({\beta,b})} \in v_{v}}{{\mathcal{C}_{\beta}\lbrack b\rbrack} \cdot {\mathcal{N}_{b}}}}{\Sigma_{{({\beta,b})} \in v_{v}}{\mathcal{N}_{b}}}$

Here, V_(v) identifies a single “v-set” (vertical set) of subband samples, consisting of one row of code-blocks from each subband that has the same vertical resolution. The subbbands that contribute to a given v-set may belong to different image components but should have the same vertical sampling rate⁴ and the same vertical code-block size, taking into account the effect of the relevant JPEG 2000 precinct partition. Thus,

_(v) can be understood as an area-weighted average complexity of the code-blocks that are found within the v-set indexed by v. ⁴By vertical resolution, we mean the rate at which subband lines appear as image lines (from the image component with the highest vertical resolution) are pushed into the wavelet transform. Apart from rounding effects, the vertical resolution of a subband is the number of lines in the subband, divided by the height of the image.

As mentioned, complexity values from different vertical resolutions may be selectively combined. To make this concrete, let

(V_(v)) denote the region spanned by the subband samples belonging to v-set V_(v), when projected onto the “high resolution grid” of the JPEG 2000 canvas coordinate system. The complexity information within v-set V_(w) is considered compatible with v-set V_(v) if

(V_(w))⊆

(V_(v)). The complexity information from compatible v-sets V_(w) may be used to augment the global complexity value

_(v) for v-set, so long as this information is available prior to the point at which the code-blocks belonging to V_(v) need to be coded. Since the vertical delay incurred due to wavelet transformation grows with depth in the multi-resolution hierarchy, we do not expect to be able to integrate complexity information from v-sets with low vertical resolutions with those having much higher vertical resolutions. In some cases, however, information from a lower resolution might be used to augment the global complexity available to v-sets at the next higher resolution, subject to constraints on latency and memory. On the other hand, it is relatively straightforward to integrate complexity information from higher resolutions into the global complexity available to v-sets at lower resolutions.

Taking these considerations into account, let

(14) denote the collection of all v-sets V_(w), including V_(v) itself, such that

(V_(w))⊆

(V_(v)) and such that the subband samples found within V_(w) are produced by the wavelet transform sufficiently ahead of the point at which the code-blocks in v-set V_(v) need to be encoded. We then define an augmented (or “unified”) global complexity value that can be used during the encoding of code-blocks in v-set V_(v) as follows:

$\mathcal{G}_{v}^{u} = \frac{\Sigma_{v_{w} \in {w{(v_{v})}}}\Sigma_{{({\beta,b})} \in v_{v}}{{\mathcal{C}_{\beta}\lbrack b\rbrack} \cdot {\mathcal{N}_{b}}}}{\Sigma_{v_{w} \in {w{(v_{v})}}}\Sigma_{{({\beta,b})} \in v_{v}}{\mathcal{N}_{b}}}$

In the simplest case,

(V_(v)) can just be V_(v) itself, so that

=

.

We now explain how the local and global complexity values affect the selection of coding passes to encode within code-block b. Let v(b) be the index of the v-set to which code-block b belongs. Then the local and global complexity information available during the encoding of code-block b consists of C_(β)[b] and

, respectively. Let C_({circumflex over (β)})[{circumflex over (b)}] and

denote the corresponding quantities, as computed in a previous frame of the video sequence, where {circumflex over (b)} and {circumflex over (β)} are the code-block and subband from the previous frame that correspond to b and β in the current frame. Since these are all logarithmic quantities, an 8-bit fixed-point representation with 2 or 3 fraction bits should be sufficient for storing them between frames, for most practical applications. The coding pass selection method of Section 0 is modified by adding an offset δ_(b) to the predicted anchor bit-plane p_({circumflex over (b)}) ^(k) discussed there. Specifically,

δ_(b)=[

−

]+α·max{0,[C _(β)[b]−C _({circumflex over (β)})[{circumflex over (b)}]]−[

−

]}

where α is a small positive constant (e.g., 0.5 or 0.25).

To understand this modification, observe firstly that an increment of δ=1 effectively doubles the quantization step size associated with the anchor bit-plane that is encoded. At face value, simply setting δ_(b)=

−

could be expected to approximately compensate for global scene complexity changes. The second term in the above expression encourages the generation of even coarser bit-planes for code-blocks whose relative complexity (local relative to global) has increased. This reduces the risk of generating too much data within code-blocks which undergo large increases in complexity that might not be compensated fully be decreases in complexity elsewhere. Essentially, the parameter α is used to manage the risk mentioned earlier, that a sudden change in complexity may result in generated coding passes that are too large for any information associated with a code-block to be included in the flush-set, resulting in large local distortions.

In the formulation above, δ_(b) is not generally integer-valued, while the predicted anchor bit-plane p_({circumflex over (b)}) ^(k), which it adjusts is necessarily an integer. Of course, δ_(b) should be rounded to an integer value, but the remaining fractional part of δ_(b) can also be taken into account in the selection of coding passes to generate. As mentioned in Section 0, the coarsest bit-plane that is actually generated may lie above or below the anchor bit-plane, depending on the actual coding pass that was selected in the previous frame, the INITIAL_CP flag, the FINAL_CP flag, and the relevant distortion-length slopes. Moreover, in typical applications at least two bit-planes are generated, usually with 3 coding passes each (Cleanup, plus SigProp and MagRef refinements). The fractional part of δ_(b) may clearly be used to bias these decisions.

Bit-Rate and Distortion-Length Slope Estimation Strategies

The algorithm described above can be understood in terms of an assumption that the bit-rate experienced when coding code-block b to bit-plane p should be of the form R₀+C_(β)[b]−p, where R₀ is a constant that does not vary from frame to frame. This is a very crude model, that we do not expect to be accurate at lower bit-rates (coarser bit-planes) where many samples are insignificant.

Much more accurate estimates of the coded bit-rate can be formed for a code-block without actually performing the encoding process. One way to do this is by forming a tally Σ_(p) of the number of significant samples that occur in each available bit-plane p=0, p=1, . . . Certainly this requires computation, but it can be much less expensive than actually performing the encoding steps. From these Σ_(p) values, one can directly determine the 1^(st) order entropy of the significance flags for each bit-plane p, and one also knows the number of magnitude and sign bits that need to be packed in the MagSgn bit-stream for each p. Allowing 1 or 2 bits for coding the unsigned magnitude exponent prediction residuals for each significant sample, one obtains a reasonable estimate for the number of bits required by the Cleanup pass at any given bit-plane p. This estimate is likely to be conservative, since the actual coding methods tend to be more efficient.

Another way to estimate the bit-rate of the encoding process is to fit a generalized Gaussian model for the probability density function of the subband samples within a code-block and use pre-computed values for the bit-rate at each bit-plane p, that depends only on the parameters of the model. To fit the model, it is sufficient to collect just two statistics for each code-block, one of which can be the mean absolute value, or equivalently the complexity estimate R₀+C_(β)[b] introduced earlier, while the other can be the mean squared value of the subband samples.

The main advantage of the model based approach over directly counting significant samples in each bit-plane is reduction in complexity. Both approaches yield a function that predicts the coded bit-rate for any given code-block, as a function of the bit-plane p. From this function, one may also derive an estimate of the operational distortion-length slope for the code-block at each bit-plane. These bit-rate and distortion-length slope estimates can be used to select a narrow set of coding passes to actually generate for each code-block, in a variety of application settings.

Beyond model based approaches, it is possible to exercise elements of the encoding process itself in order to directly count the number of bits that would be emitted to specific bit-streams, prior to bit-stuffing. Since bit-stuffing cannot increase the coded length by more than 1 bit in every 15, and rarely has any significant impact at all, this method can be used to produce very accurate estimates of the coded lengths of a multitude of coding passes, without actually generating the coded bit-streams. In triple bit-stream variants of the Cleanup pass, with distributed magnitude coding, the number of bits emitted to the MagSgn and VLC bit-streams, prior to bit-stuffing, can be determined by replacing the VLC codeword tables with lookup tables that return the sum of the number of VLC bits, the number of significant samples, and the number of residual magnitude bits for each group. This requires at most two table lookup operations per group of 4 samples. Tallying these values provides a good estimate of the total number of bits produced by the Cleanup pass, which can be improved by estimating or directly calculating the number of bits produced by the adaptive run-length coding of group significance symbols. The number of bits produced by a MagRef pass, prior to bit-stuffing, is simply the number of samples that are significant in the preceding Cleanup pass. The number of bits produced by a SigProp pass is more expensive to calculate exactly, since it requires the propagation of significance procedure to be followed, but it is nonetheless significantly cheaper to compute than actually generating the SigProp bit-stream.

Embodiments of the invention can use a combination of direct bit-counting and model-based estimation strategies to obtain good estimates of the operational rate-distortion properties of a set of coding passes, using this information to facilitate the selection of a small set of coding passes to actually generate. For example, in some embodiments, the actual number of bits produced by the Cleanup pass can be calculated for the four most significant bit-planes of a code-block that contain at least one significant sample, after which model-based approaches can be used for succeeding bit-planes, to form a complete estimate of the distortion-length characteristic at Cleanup pass boundaries.

In a variable bit-rate setting (VBR), we arrange for the distortion-length slope threshold T_(γ) ^(k) ^(gen) to change only slowly from frame to frame, even though this may mean that the coded size of each frame varies. An outer loop adjusts T_(γ) ^(k) ^(gen) slowly over time so as to maintain a target average bit-rate; this is usually done via the classic “leaky bucket” model. In such applications, the PCRD-opt algorithm is driven directly by the threshold T_(γ) ^(k) ^(gen) , which is known prior to the point at which code-blocks are actually encoded, so the distortion-length slope estimates for each bit-plane p can be used to determine the coding passes that should be generated for a code-block.

Specifically, if the estimates can be relied upon to be conservative, it is sufficient to find the smallest (i.e., highest quality) p such that the estimated distortion length slope is larger than T_(γ) ^(k) ^(gen) , generating the Cleanup pass for this p, followed by one or perhaps two higher quality (smaller p) Cleanup passes, along with their respective SigProp and MagRef coding passes. The actual PCRD-opt algorithm then operates with this limited set of generated coding passes.

In a constant bit-rate (CBR) setting, the estimated bit-rates and distortion-length slopes for each code-block in a v-set V_(v), or in the larger set

(V_(v)), to which it belongs, can be used to simulate the expected behaviour of the PCRD-opt algorithm, to determine the bit-plane (if any) whose Cleanup pass we expect to include in the codestream for each code-block. Again, assuming that the estimates are conservative, meaning that the actual block coder is more efficient than the estimate suggests, it is then sufficient to generate just this estimated Cleanup pass, plus one or two higher quality (i.e., smaller p) Cleanup passes, along with their respective SigProp and MagRef coding passes. The actual PCRD-opt algorithm then operates with this limited set of generated coding passes.

It will be appreciated that there are a number of distinctive features of the process and apparatus of the present invention, exemplified in the above description of the preferred embodiment. Advantageous features of the embodiment are briefly discussed below. Please note that the invention is not limited to these features, and that embodiments may include some or all of these features or may not include these features and may utilize variations.

-   A. The coding of significance is carried out on groups (group size 4     is preferred) -   B. The coding of significance precedes other coding steps in several     ways:     -   a. First, in preferred embodiments the significance of a         specific subset of groups (known as the AZC groups) is coded         using an adaptive coding engine that generates its own         bit-stream.     -   b. Other significance information is coded on a group basis,         before the magnitude and sign information for significant         samples is coded.     -   c. In dual bit-stream embodiments, significance information is         coded for one entire line of code-block samples, before the         magnitude and sign information for those samples is coded, after         which the next line is processed, and so forth.     -   d. In triple bit-stream embodiments, significance encoding and         decoding are fully decoupled from magnitude and sign coding         processes, so that significance can be encoded in any order,         while decoders can recover significance information either         concurrently or ahead of the final magnitude and sign         information, by any desired margin. -   C. Significance coding is based on group contexts, where the context     of a group depends only on the significance information that has     already been coded within the code-block. -   D. The coding of the significance makes use of variable length     coding, with a single codeword emitted for each group that is not     otherwise known to be entirely insignificant, where the codewords     depend upon the group context. -   E. The coding of magnitude information for significant samples makes     use of magnitude exponents associated with magnitudes that have     already been coded. These are used to form a context, or predictor,     with respect to which an upper bound on the magnitude exponents of     significant samples is coded. This bound determines the number of     additional magnitude bits which must be emitted to a raw bit-stream,     along with the sign bit, for significant samples.

In embodiments, the sum of the neighbouring magnitude exponents is used to form the context mentioned above, with 2 preceding neighbours used in the first line of the code-block and 4 neighbours (left, above-left, above and above-right) for all other lines in the code-block.

-   F. The magnitude coding context is converted to a predictor G, then     a comma code is used to encode R=max{0,E−1-G}, where E is the     magnitude exponent (necessarily non-zero) of the significant sample,     after which the sign and R+G least significant magnitude bits are     emitted if R>0, else the sign and R+G+1 magnitude bits are emitted. -   G. In other embodiments, magnitude exponent bounds are coded in     groups, being the same groups for which significance is coded. In     such embodiments, a predictor for these bounds is formed based on     previously coded magnitudes, preferably from a prior row of groups     within the code-block, and a prediction residual is coded to     identify the difference between the predicted bounds and the actual     bounds, which need not be tight. In preferred embodiments, the     prediction residual is coded using a variable length code,     generating one codeword for each group that contains at least one     significant sample. Preferably, these residual codewords are     interleaved with the variable length codewords that code     significance for the same groups, allowing exponent bound residual     codewords and significance codewords to be decoded ahead of the     point at which the actual magnitude bits and sign of the significant     samples need to be unpacked from the same or a different raw     bit-stream. The coded magnitude bound residuals do not in general     provide a self-contained description of the magnitudes or even the     magnitude exponents, since the predictors are based on magnitudes     that must first be decoded. -   H. The use of an additional SigProp coding pass for each code-block     that encodes the same information as the JPEG2000 Significance     Propagation coding pass for the corresponding bit-plane. In     embodiments, this coding pass emits significance and sign bits to a     raw codeword segment. In some embodiments, the original JPEG2000     Significance Propagation pass may be used for this purpose,     operating in the “adaptive coder BYPASS mode.” In embodiments, the     original JPEG2000 Significance Propagation pass is modified such     that the relevant significance bits associated with a set of samples     are emitted to the raw bit-stream ahead of the corresponding sign     bits for that set of samples, rather than interleaving significance     and sign bits on a sample by sample basis. Preferred embodiments     perform this interleaving on the basis of a set of 4 samples.     Embodiments may include the additional modification that bits are     packed into the bytes of the raw bit-stream with a little-endian,     rather than big-endian bit order. -   I. The use of an additional MagRef coding pass for each code-block     that encodes the same information as the JPEG2000 Magnitude     Refinement coding pass for the corresponding bit-plane. In     embodiments, this coding pass emits refinement bits to a raw     codeword segment. In some embodiments, this coding pass may be     identical to the original JPEG2000 Magnitude Refinement coding pass,     operating in the “adaptive coder BYPASS mode.” In embodiments, the     JPEG2000 Magnitude Refinement pass is modified by packing bits into     the bytes of the raw bit-stream with a little-endian, rather than     big-endian bit order. -   J. An image encoding method in which Cleanup passes are generated     for one or more bit-planes of each code-block, together with SigProp     and MagRef coding passes for some or all of said bit-planes, along     with distortion estimates for the various coding passes, wherein the     actual coding passes emitted to the final codestream are selected     from those generated on the basis of a rate-distortion optimization     step. -   K. The above method in which the coarsest bit-plane for which coding     passes are generated within a code-block is determined based on the     coarsest bit-plane for which coding passes are emitted to the     codestreams of previous frames in a video sequence, from code-blocks     that are similar, where similarity is measured in terms of spatial     location and the subband to which the code-blocks belong. -   L. The above method in which the coasest bit-plane for which coding     passes are generated within a code-block is determined subject to a     subband specific maximum data rate objective, that is inferred from     the behaviour of the rate control process in preceding frames. -   M. The above method in which the full set of coding passes that are     generated within a code-block is determined based on a small set of     summary statistics that are collected the same code-block in a     previous frame, together with information about the coding passes     that were selected by the rate-distortion optimization step for the     code-block in said previous frame. -   N. In embodiments, the above methods are modified by adjusting the     coarsest bit-plane for which coding passes are generated up or down     based on complexity estimates, which are indicative of the     compressibility of each code-block and larger regions within the     image. Embodiments employ a complexity estimate which is formed by     accumulating the absolute values of subband samples within each     code-block and taking an approximate logarithm of the result.     Complexity values of this form are generated and stored, so that     local and more global complexity comparisons can be formed around     each code-block, relative to previously compressed content whose     rate-distortion optimization outcomes are used as the reference to     determine the bit-planes for which coding passes are being     generated. -   O. In embodiments, the above methods are modified by the     incorporation of rate and distortion-length slope estimates for each     code-block that are formed variously from the fitting of statistical     models for the subband samples to summary statistics accumulated for     each code-block, or from the counting of significant samples within     the code-block at each of a plurality of magnitude bit-planes. 

1. A method of image compression, where image samples are formed into code-blocks, with a block coding process that comprises the following steps: coding significance information for a set of samples, using codes that depend only on the significance of previous samples in a scanning order; coding magnitude and sign information for a set of samples, using codes that depend only on previous magnitude and significance information in the scanning order; arranging the significance and magnitude code bits on a set by set basis, such that the significance bits associated with each set of samples appear together in the coded representation (codeword segment); repeating the coding and code bit arrangement steps for each set of samples in the code-block.
 2. A method in accordance with claim 1, wherein the block coding process comprises the step of collecting the samples of the code-blocks into groups, so that a set of samples comprises a group of samples, and the significance coding step is applied to the groups of samples.
 3. A method in accordance with claim 2, wherein each group comprises four samples.
 4. A method in accordance with claim 1, 2 or 3, wherein group significance signals are coded for certain groups within the code block, using an adapative code to communicate whether each such group contains any significant samples, or no significant samples at all.
 5. A method in accordance with any one of claims 1 to 4, wherein the block coding process comprises the step of producing a single codeword segment which comprises a plurality of bit-streams.
 6. A method in accordance with claim 5, wherein the single codeword segment is produced by a forward growing bit-stream and a backward growing bit-stream (dual bit-stream), whereby the lengths of the individual bit-streams do not need to be separately communicated.
 7. A method in accordance with claim 5, wherein the single codeword segment is produced by three bit-streams (triple bit-stream), two growing forward, while one grows backward, and wherein the interface between the two forward growing bit-streams and the overall length of the codeword segment are explicitly identified.
 8. A method in accordance with any one of claims 1 to 7, wherein bits produced by adaptive coding of group significance symbols are assigned to their own bit-stream (adaptively coded bit-stream) within the code-block's codeword segment.
 9. A method in accordance with any one of claims 1 to 8, wherein group significance signals are coded using an adaptive arithmetic coding engine.
 10. A method in accordance with any one of claims 1 to 8, wherein group significance signals are coded using an adaptive run-length coding engine.
 11. A method in accordance with any one of claims 1 to 10, wherein the step of coding significance for a set of samples is based on context, the context of a set of samples depending only on the significance information that has already been coded for previous sets of samples in the code-block, in scan-line order.
 12. A method in accordance with claim 11, wherein the step of context-based significance coding utilizes variable length codes, and a single codeword is emitted for each set of samples that is not otherwise know to be entirely insignificant.
 13. A method in accordance with claim 12, wherein the bits produced by context-based significance coding are arranged within a bit-stream (a raw bit-stream) that is separate from the adaptively coded bit-stream.
 14. A method in accordance with any one of claims 1 to 13, wherein the step of coding magnitude information is based on magnitude contexts, wherein the magnitude context for each sample is formed from the magnitude exponents of its neighbours.
 15. A method in accordance with claim 14, wherein the magnitude context is formed from the magnitude exponents of previously coded sample magnitudes.
 16. A method in accordance with any one of claims 11 to 15, wherein the bits used to encode magnitude and sign information for significant samples of a code-block are arranged within the same bit-stream (raw bit-stream) as the context-based significance code bits, but separated so that the significance bits for a set of samples appears before the magnitude and sign bits for the same set of samples.
 17. A method in accordance with any one of claims 11 to 15, wherein the bits used to encode magnitude and sign information are arranged within a separate bit-stream (a raw bit-stream) from the context-based significance code-bits.
 18. A method in accordance with any one of claims 11 to 15, wherein magnitude and sign information for significant samples is separated into a variable length coded part and an uncoded part, where the bits produced by the variable length coded part are arranged within the same bit-stream (VLC bit-stream) as the context-based significance code bits, while the uncoded part is arranged within a separate bit-stream (a raw bit-stream).
 19. A method in accordance with any one of claims 1 to 18, wherein the step of coding magnitude and sign information involves the step of coding the number of bits of magnitude information that need to be included in the raw bit-stream for each significant sample.
 20. A method in accordance with claim 19, wherein the step of coding the number of bits of magnitude information that need to be included in the raw bit-stream for each significant sample is based on magnitude context, wherein the magnitude context is formed from the magnitude exponents of neighbouring samples.
 21. A method in accordance with claim 20, wherein the magnitude context is formed from the sum of the neighbouring sample magnitude exponents.
 22. A method in accordance with claim 21, wherein the neighbouring samples used are the two preceding neighbours in the first line of the code-block and four neighbours (left, above-left, above and above-right) for all other lines in the code-block.
 23. A method in accordance with any one of claims 19 to 22 wherein the magnitude of a significant sample is encoded in two parts, one for the magnitude exponent and one for the sign and magnitude bits.
 24. A method in accordance with claim 23, where the magnitude exponent part is arranged to be decoded revealing the magnitude exponent without decoding the sign and magnitude bits part.
 25. A method in accordance with claim 23 or claim 24, wherein the magnitude exponent part of the code is encoded by a comma code that is used to encode U=max (0,E−1-G) with the occurrence of the event U is greater than G, where E is the magnitude exponent of the significant sample and G is a predictor generated from the magnitude coding context, to encode U−1 followed by 0 with the occurrence of events G is greater or equal to U and U is greater than 0, to encode P=G−(E1) followed by 1 with the occurrence of events U is 0 and P is less than G, and to encode G with the occurrence of the events U is 0 and P is equal to G, where all encoded bits are emitted to a raw bit-stream.
 26. A method in accordance with claim 20, 21 or 22, wherein the magnitude coding context is converted to a predictor G, a comma code is used to encode U=max (0,E−1-G), where E is the magnitude exponent of the significant sample, after which the sign and U+G−1 least significant magnitude bits are emitted if U is greater than 0, else the sign and U+G magnitude bits are emitted, where all bits are emitted to a raw bit-stream.
 27. A method in accordance with claim 20, 21 or 22, wherein the magnitude coding context is converted to a predictor G, a context dependent Rice mapping is applied to the signed prediction residual E−1-G to form R, a comma code is used to encode R, after which the sign and E−2 least significant magnitude bits are emitted if E is greater than 2, else the sign bit alone is emitted, where all bits ae emitted to a raw bit-stream.
 28. A method in accordance with claim 19 or claim 20, wherein the step of coding the number of magnitude bits that need to be included in the raw bit-stream for significant samples is performed on a group basis, wherein a sufficient number of bits to include for each significant sample in a group is coded as the sum of a predicted number of magnitude bits and a prediction residual which applies to all significant samples in the group.
 29. A method in accordance with claim 28, where the predicted number of magnitude bits for significant samples in a group is determined using the magnitude exponent values of samples belonging to other groups, for which magnitude information has already been coded.
 30. A method in accordance with claim 29 and claim 19, where the prediction residual used to identify magnitude bits for significant samples in a group is coded using a variable length code, whose bits are emitted after those of the variable length code used to code significant sample in the same group.
 31. A method in accordance with claim 30, where the prediction residual and significance codeword bits are interleaved within the same bit-stream.
 32. A method in accordance with claim 31, where the interleaving of residual and significance codeword bits is such that the significance codewords for each pair of consecutive groups are followed by the prediction residual codewords for these same groups, if they contain significant samples, being followed by the significance codewords for the next pair of consecutive groups, and so forth.
 33. A method in accordance with any one of claims 1 to 32, wherein the method of image compression complies with the JPEG 2000 format, and the block coding process of any one of claims 1 to 32 is used in place of the usual JPEG 2000 block coding process.
 34. A method in accordance with any one of claims 1 to 33, wherein the steps of significance and magnitude coding (Cleanup pass) produce a codeword segment (Cleanup segment) that communicates quantized subband samples within a code-block relative to a certain magnitude bit-plane.
 35. A method in accordance with claim 34, wherein an additional codeword segment (SigProp segment) is produced that represents the significance of certain samples within the code-block that were coded as insignificant in the Cleanup pass, relative to the next finer (higher precision) magnitude bit-plane, along with the sign information for samples that are significant only relative to this finer bit-plane.
 36. A method in accordance with claim 34, wherein a further codeword segment (MagRef segment) is produced that holds the least significant magnitude bit, with respect to the finer (higher precision) bit-plane, for samples that are coded as significant in the Cleanup pass.
 37. A method in accordance with any one of claims 5 to 22, wherein bit-streams are subjected to a bit-stuffing procedure.
 38. A method in accordance with any one of claims 1 to 37, comprising the step of implementing a Significance Propagation coding pass for each code-block.
 39. A method in accordance with claim 38, wherein the Significance Propagation pass emits significance and sign bits to a raw codeword segment.
 40. A method in accordance with claim 39, wherein the significance bits associated with a set of samples are emitted together, followed by any sign bits for this set of samples, being followed by the significance bits for the next set of samples, and so forth.
 41. A method in accordance with claim 40, wherein the sample sets that determine the interleaving pattern for significance and sign bits consist of 4 samples.
 42. A method in accordance with any one of claims 1 to 41, comprising the step of implementing a Magnitude Refinement coding pass for each code-block.
 43. A method in accordance with claim 42, wherein the Magnitude Refinement pass emits refinement bits to a raw codeword segment.
 44. A method of image compression, where image samples are formed into code-blocks, comprising a block coding process having the following steps: coding significance information for a set of samples; subsequently coding magnitude and sign information for the set of samples; repeating the coding and subsequent coding steps for other sets of samples until significance, sign and magnitude information has been coded for all the sets of samples in the code-block.
 45. A method in accordance with claim 44, wherein the block coding process comprises the step of collecting the samples of the code-blocks into groups, so that a set of samples comprises a group of samples, and the coding and subsequent coding steps are applied to the groups of samples.
 46. A method in accordance with claim 45, wherein each group comprises four samples.
 47. A method in accordance with claim 45 or claim 46, wherein the block coding process further comprises the step of coding a subset of the groups using an adaptive coding engine that generates its own bit-stream.
 48. A method in accordance with claim 47, wherein the adaptive coding engine that generates its own bit-stream is an arithmetic coding engine.
 49. A method in accordance with claim 47, wherein the adaptive coding engine that generates its own bit-stream is an adaptive run-length coding engine.
 50. A method in accordance with claim 47, 48 or 49 wherein the remaining significance information, that has not been coded by the adaptive coding engine, is coded to provide a raw bit-stream.
 51. A method in accordance with claim 50, the block coding process comprising the step of producing a single codeword segment comprising a plurality of bit-streams.
 52. A method in accordance with claim 51, wherein the codeword segment comprises two parts, the first part comprising the bit-stream generated by the coding engine and the second part comprising a raw bit-stream.
 53. A method in accordance with claim 52, wherein the codeword segment comprises three parts, one part comprising the bit-stream generated by the adaptive coding engine, a second part comprising the raw bit-stream that holds significance information that is not encoded within the first part, and a third part comprising a second raw bit-stream that holds magnitude and sign information not encoded within the other two parts.
 54. A method in accordance with any one of claims 44 to 50, wherein the block coding process comprises the step of producing a single codeword segment containing significance, sign and magnitude information, the single codeword segment comprising a plurality of parts, each part coded by a different coding process.
 55. A method in accordance with any one claims 44 to 54, wherein the step of coding significance information is based on context, the context of a set of samples depending only on the significance information that has already been coded for sets of samples in the code-block.
 56. A method in accordance with claim 55, wherein the step of coding significance information utilizes variable length coding, and wherein a single codeword is emitted for each set of samples that is not otherwise known to be entirely insignificant.
 57. A method in accordance with any one of claims 44 to 56, wherein the step of coding magnitude and sign information involves the step of coding the number of bits of magnitude information that need to be included in the raw bit-stream for each significant sample.
 58. A method in accordance with claim 57, wherein the step of coding the number of bits of magnitude information that need to be included in the raw bit-stream for each significant sample is based on magnitude context, wherein the magnitude context is formed from the magnitude exponents of neighbouring samples.
 59. A method in accordance with claim 58, wherein the magnitude context is formed from the sum of the neighbouring sample magnitude exponents.
 60. A method in accordance with claim 59, wherein the neighbouring samples used are the two preceding neighbours in the first line of the code-block and four neighbours (left, above-left, above and above-right) for all other lines in the code-block.
 61. A method in accordance with any one of claims 57 to 60 wherein the magnitude of a significant sample is encoded in two parts, one for the magnitude exponent and one for the sign and magnitude bits.
 62. A method in accordance with claim 61, where the magnitude exponent part is arranged to be decoded revealing the magnitude exponent without decoding the sign and magnitude bits part.
 63. A method in accordance with claim 61 or claim 62, wherein the magnitude exponent part of the code is encoded by a comma code that is used to encode U=max (0,E−1-G) with the occurrence of the event U is greater than G, where E is the magnitude exponent of the significant sample and G is a predictor generated from the magnitude coding context, to encode U−1 followed by 0 with the occurrence of events G is greater or equal to U and U is greater than 0, to encode P=G−(E1) followed by 1 with the occurrence of events U is 0 and P is less than G, and to encode G with the occurrence of the events U is 0 and P is equal to G, where all encoded bits are emitted to a raw bit-stream.
 64. A method in accordance with claim 58, 59 or 60, wherein the magnitude coding context is converted to a predictor G, a comma code is used to encode U=max (0,E−1-G), where E is the magnitude exponent of the significant sample, after which the sign and U+G−1 least significant magnitude bits are emitted if U is greater than 0, else the sign and U+G magnitude bits are emitted, where all bits are emitted to a raw bit-stream.
 65. A method in accordance with claim 58, 59 or 60, wherein the magnitude coding context is converted to a predictor G, a context dependent Rice mapping is applied to the signed prediction residual E−1-G to form R, a comma code is used to encode R, after which the sign and E−2 least significant magnitude bits are emitted if E is greater than 2, else the sign bit alone is emitted, where all bits ae emitted to a raw bit-stream.
 66. A method in accordance with claim 57, wherein the step of coding the number of magnitude bits that need to be included in the raw bit-stream for significant samples is performed on a group basis, wherein a sufficient number of bits to include for each significant sample in a group is coded as the sum of a predicted number of magnitude bits and a prediction residual which applies to all significant samples in the group.
 67. A method in accordance with claim 66, where the predicted number of magnitude bits for significant samples in a group is determined using the magnitude exponent values of samples belonging to other groups, for which magnitude information has already been coded.
 68. A method in accordance with claim 65 and claim 56, where the prediction residual used to identify magnitude bits for significant samples in a group is coded using a variable length code, whose bits are emitted after those of the variable length code used to code significant sample in the same group.
 69. A method in accordance with claim 68, where the prediction residual and significance codeword bits are interleaved within the same bit-stream.
 70. A method in accordance with claim 69, where the interleaving of residual and significance codeword bits is such that the significance codewords for each pair of consecutive groups are followed by the prediction residual codewords for these same groups, if they contain significant samples, being followed by the significance codewords for the next pair of consecutive groups, and so forth.
 71. A method in accordance with claim 51, 52, 53, 59, 38 or 60, wherein bit-streams are subjected to a bit-stuffing procedure.
 72. A method in accordance with any one of claims 44 to 63, comprising the step of implementing a Significance Propagation coding pass for each code-block.
 73. A method in accordance with claim 72, wherein the Significance Propagation pass emits significance and sign bits to a raw codeword segment.
 74. A method in accordance with claim 73, wherein the significance bits associated with a set of samples are emitted together, followed by any sign bits for this set of samples, being followed by the significance bits for the next set of samples, and so forth.
 75. A method in accordance with claim 74, wherein the sample sets that determine the interleaving pattern for significance and sign bits consist of 4 samples.
 76. A method in accordance with any one of claims 44 to 75, comprising the step of implementing a Magnitude Refinement coding pass for each code-block.
 77. A method in accordance with claim 76, wherein the Magnitude Refinement pass emits refinement bits to a raw codeword segment.
 78. A method in accordance with any one of claims 1 to 77, wherein the method of image compression complies with the JPEG 2000 format, and the block coding process of any of claims 1 to 77 is used in place of the usual JPEG 2000 block coding process.
 79. An encoding apparatus, arranged to implement an image processing method in accordance with any one of the preceding claims.
 80. An encoding apparatus, comprising a block coder arranged to code significance information for a set of samples, to subsequently code magnitude and sign information for the set of samples, and to repeat the coding and subsequent coding steps for other sets of samples until significance, sign and magnitude information has been coded for all the sets of samples in a code-block.
 81. A computer program, comprising instructions for controlling a computer to implement a method in accordance with any one of claims 1 to
 78. 82. A non-volatile computer readable medium, providing a computer program in accordance with claim
 81. 83. A data signal, comprising a computer program in accordance with claim
 82. 84. In a method of image compression complying with the JPEG2000 standard, wherein image samples are formed into code-blocks by a block coding process, the improvement comprising implementing a Cleanup pass in the block coding process, which encodes the information that would be encoded by a corresponding JPEG2000 Cleanup pass, along with the information that would be encoded by all corresponding preceding JPEG2000 coding passes.
 85. A method in accordance with claim 84, wherein a plurality of Cleanup passes, Significance Propagation passes and Magnitude Refinement passes are generated for each code-block in the image, each Cleanup pass for a code-block being associated with a distinct bit-plane, and each Significance Propagation and Magnitude Refinement pass representing a refinement of a Cleanup pass, whereupon a post-compression rate-distortion optimization process is used to select the specific Cleanup pass to be included in the final compressed result for each code-block and whether or not to include any Significance Propagation pass or Magnitude Refinement pass associated with that Cleanup pass.
 86. A method in accordance with claim 85, wherein the set of bit-planes for which coding passes are generated for a code-block is determined based on the bit-planes that have been selected for inclusion from similar code-blocks, when compressing similar images, by the post-compression rate distortion optimization procedure.
 87. A method in accordance with claim 86, where the images being compressed belong to a video sequence, where said similar images correspond to previously compressed frames from the video sequence, and said similar code-blocks correspond to similarly located blocks within the same subbands of said similar frames.
 88. A method in accordance with claim 86 or claim 87, where the bit-planes for which coding passes are generated depend additionally upon a measure of complexity that is related to the estimated compressibility of the imagery.
 89. A method in accordance with claim 88, where the complexity is assessed for the code-blocks and the image that are being compressed, as well as said similar code-blocks and images, with difference in complexity being used to adjust the set of bit-planes for which coding passes are generated.
 90. A method in accordance with claim 88 or claim 89, where the measure of complexity is derived by accumulating subband sample magnitudes within code-blocks and taking an approximate logarithm of the result.
 91. A method in accordance with any of claims 85 to 90, where coded lengths and distortion-length slopes for a plurality of coding passes, corresponding to a plurality of bit-planes, are estimated and used to measure complexity, these estimates being used to determine the set of bit-planes for which coding passes are generated for a code-block.
 92. A method in accordance with claim 91, where coded length estimates are based on counting the number of significant samples found in a code-block at each of a plurality of bit-planes.
 93. A method in accordance with claim 91, where coded length and distortion estimates are based on parametric models for the probability density function of the subband samples found in a code-block, the parameters for such models being formed from summary statistics that are computed from the code-block's sample values.
 94. A method in accordance with claim 91, where coded length estimates are obtained by executing elements of the encoding process that are sufficient to reveal the number of bits that will be emitted to individual bit-streams prior to bit-stuffing.
 95. A method in accordance with any one of claims 85 to 94, wherein the block coding process is in accordance with the method of any one of claims 1 to
 78. 96. An encoding apparatus, arranged to implement a method in accordance with any one of claims 85 to
 95. 